# Self referential belongs\_to

**URL:** <https://www.ruby-forum.com/t/self-referential-belongs-to/141471>\
**Category:** Ruby\
**Created:** [June 26, 2008, 5:42am UTC](https://www.ruby-forum.com/t/self-referential-belongs-to/141471 "2008-06-26T05:42:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ericgoodwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c68b51/32.png) [@ericgoodwin](https://www.ruby-forum.com/u/ericgoodwin)\
**Post date:** [June 26, 2008, 5:42am UTC](https://www.ruby-forum.com/t/self-referential-belongs-to/141471/1 "2008-06-26T05:42:00Z")

</div>

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 =\>  
“flipped\_layout\_id”  
end

So when I do, Layout.find(:all, :include =\> :flipped\_layout), it locks  
up.

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