Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > self referential belongs_to

Thread Tools

self referential belongs_to

Aryk Grosz
Posts: n/a
I noticed that eager loading a belongs to association that points back
to an item of the same class is causing AR to lock up.

For example

class Layout < ActiveRecord::Base

belongs_to :flipped_layout, :class_name => "Layout", :foreign_key =>

So when I do, Layout.find(:all, :include => :flipped_layout), it locks

Am I doing something wrong or this a known bug with Rails?
Posted via

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
why doesn't this "belongs_to" line of code, using options override,not work??? (need help using belongs_to with options) Greg Hauptmann Ruby 1 10-30-2008 10:44 PM
[J2EE Entity EJBs] Many-Many Self-Referential Relationships John Java 0 05-24-2004 02:17 PM
Self-referential initialization Risto Lankinen C++ 1 11-13-2003 01:42 PM
self referential template parameters? SpeedBump C++ 1 11-04-2003 08:10 AM
typenames in self-referential templates Anthony Heading C++ 9 09-25-2003 07:21 PM