# ActiveRecord::ConfigurationError in Rails 2.0

**URL:** <https://www.ruby-forum.com/t/activerecord-configurationerror-in-rails-2-0/132960>\
**Category:** Rails\
**Created:** [March 26, 2008, 5:17am UTC](https://www.ruby-forum.com/t/activerecord-configurationerror-in-rails-2-0/132960 "2008-03-26T05:17:06Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![vinay](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/6a8cbe/32.png) [@vinay](https://www.ruby-forum.com/u/vinay)\
**Post date:** [March 26, 2008, 5:17am UTC](https://www.ruby-forum.com/t/activerecord-configurationerror-in-rails-2-0/132960/1 "2008-03-26T05:17:06Z")

</div>

Hi,  
I recently gathered guts and tried implementing the Rails 2.0.2 in one  
of my existing application that was running on Rails 1.2.3. I ran in to  
a strange issue.  
I have a model **Post** and a model  
**Comment**. They have the very general has\_many and  
belongs\_to relationship. Now when I try to implement a join b/w the two  
models.

`
Post.rb
class Post < ActiveRecord::Base
  has_many :comments
end
Comment.rb
class Comment < ActiveRecord::Base
belongs_to :post
end
`  
Now when I try to do a  
`
post = Post.find(:first, :joins=>[“p LEFT OUTER JOIN comments c ON
p.id=c.post_id”], :select=>[“p.id as post_id, c.id as comment_id, p.body
as post_body and c.body as comment_body”])
`

It throws me a  
`
ActiveRecord::ConfigurationError (Association named ‘u LEFT OUTER JOIN
comments c ON p.id=c.post_id’ was not found; perhaps you misspelled
it?):
`

---

<div class="post-metadata">

**Author:** ![vinay](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/6a8cbe/32.png) [@vinay](https://www.ruby-forum.com/u/vinay)\
**Post date:** [March 26, 2008, 9:03am UTC](https://www.ruby-forum.com/t/activerecord-configurationerror-in-rails-2-0/132960/2 "2008-03-26T09:03:54Z")

</div>

On 26 Mar 2008, at 04:17, jazzy jazzy wrote:

> models.

> it?):  
>   
> You used to be able to pass an array to :joins, if you do that now it  
> will interpret it as a list of association names (eg :comments etc…)  
> Pass a string if you don’t want that to happen.

Fred

---

<div class="post-metadata">

**Author:** ![vinay](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/6a8cbe/32.png) [@vinay](https://www.ruby-forum.com/u/vinay)\
**Post date:** [March 26, 2008, 9:49am UTC](https://www.ruby-forum.com/t/activerecord-configurationerror-in-rails-2-0/132960/3 "2008-03-26T09:49:13Z")

</div>

jazzy jazzy wrote:

> post = Post.find(:first, :joins=\>[“p LEFT OUTER JOIN comments c ON  
> p.id=c.post\_id”], :select=\>[“p.id as post\_id, c.id as comment\_id, p.body  
> as post\_body and c.body as comment\_body”])

Also, this is more commonly written:

post = Post.find :first, :include =\> :comments

Let Rails worry about the join for you…

---

<div class="post-metadata">

**Author:** ![vinay](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/6a8cbe/32.png) [@vinay](https://www.ruby-forum.com/u/vinay)\
**Post date:** [March 26, 2008, 10:41am UTC](https://www.ruby-forum.com/t/activerecord-configurationerror-in-rails-2-0/132960/4 "2008-03-26T10:41:48Z")

</div>

Mark B. wrote:

> jazzy jazzy wrote:
> 
> > post = Post.find(:first, :joins=\>[“p LEFT OUTER JOIN comments c ON  
> > p.id=c.post\_id”], :select=\>[“p.id as post\_id, c.id as comment\_id, p.body  
> > as post\_body and c.body as comment\_body”])
> 
> Also, this is more commonly written:
> 
> post = Post.find :first, :include =\> :comments
> 
> Let Rails worry about the join for you…

Thanks for your immediate reply Mark B… I could have used the  
:include attribute of the find method but I wanted only the selected  
columns to load due to performance issues. Hence the question.

---

<div class="post-metadata">

**Author:** ![vinay](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/6a8cbe/32.png) [@vinay](https://www.ruby-forum.com/u/vinay)\
**Post date:** [March 26, 2008, 10:48am UTC](https://www.ruby-forum.com/t/activerecord-configurationerror-in-rails-2-0/132960/5 "2008-03-26T10:48:45Z")

</div>

On 26 Mar 2008, at 09:44, jazzy jazzy wrote:

> > will interpret it as a list of association names (eg :comments  
> > models. Did the Core team market this change? Think it was something I  
> > missed or was using it the way it was not meant to be used from  
> > Version  
> > 1.2.3!. Any ways thanks once again.

:joins doesn’t eager load: it just creates the join statements for you.

Fred

---

<div class="post-metadata">

**Author:** ![vinay](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/6a8cbe/32.png) [@vinay](https://www.ruby-forum.com/u/vinay)\
**Post date:** [March 26, 2008, 10:44am UTC](https://www.ruby-forum.com/t/activerecord-configurationerror-in-rails-2-0/132960/6 "2008-03-26T10:44:27Z")

</div>

Frederick C. wrote:

> On 26 Mar 2008, at 04:17, jazzy jazzy wrote:
> 
> > models.
> 
> > it?):  
> >   
> > You used to be able to pass an array to :joins, if you do that now it  
> > will interpret it as a list of association names (eg :comments etc…)  
> > Pass a string if you don’t want that to happen.
> 
> Fred

Fred,  
Thanks for the immediate reply. The fix that you mentioned worked great.  
It is strange though why this sudden change in direction. There was  
always the include that could be used to eager load the associated  
models. Did the Core team market this change? Think it was something I  
missed or was using it the way it was not meant to be used from Version  
1.2.3!. Any ways thanks once again.

---

<div class="post-metadata">

**Author:** ![vinay](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/6a8cbe/32.png) [@vinay](https://www.ruby-forum.com/u/vinay)\
**Post date:** [March 26, 2008, 11:59am UTC](https://www.ruby-forum.com/t/activerecord-configurationerror-in-rails-2-0/132960/7 "2008-03-26T11:59:56Z")

</div>

On 26 Mar 2008, at 10:52, jazzy jazzy wrote:

> > 
> 
> that I was trying to make in my reply to you was that  
> earlier(referring  
> to Rails 1.2.3 that I last used) the :joins accepted an array but like  
> you pointed out very rightly that joins did not accept array come  
> Rails  
> 2.0 onwards and only accepted string. This was bit strange to me. I  
> mean  
> this was not mentioned in the docs. Was joins never expected to accept  
> an array? Was I doing it all wrong all the way?

Doesn’t look like it was ever documented to accept an array. The rdoc  
in 1.2.3 says ‘An SQL fragment for additional joins like “LEFT JOIN  
comments ON comments.post\_id = id”. (Rarely needed)’. The old  
implementation just happened to work if you passed an array with a  
single element.

Fred

---

<div class="post-metadata">

**Author:** ![vinay](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/6a8cbe/32.png) [@vinay](https://www.ruby-forum.com/u/vinay)\
**Post date:** [March 26, 2008, 11:52am UTC](https://www.ruby-forum.com/t/activerecord-configurationerror-in-rails-2-0/132960/8 "2008-03-26T11:52:00Z")

</div>

Frederick C. wrote:

> On 26 Mar 2008, at 09:44, jazzy jazzy wrote:
> 
> > > will interpret it as a list of association names (eg :comments  
> > > models. Did the Core team market this change? Think it was something I  
> > > missed or was using it the way it was not meant to be used from  
> > > Version  
> > > 1.2.3!. Any ways thanks once again.
> 
> :joins doesn’t eager load: it just creates the join statements for you.
> 
> Fred

Hi Fred,  
Thanks for the immediate response again. I am aware of the fact that the  
joins attribute of the find method generates a join query. But the point  
that I was trying to make in my reply to you was that earlier(referring  
to Rails 1.2.3 that I last used) the :joins accepted an array but like  
you pointed out very rightly that joins did not accept array come Rails  
2.0 onwards and only accepted string. This was bit strange to me. I mean  
this was not mentioned in the docs. Was joins never expected to accept  
an array? Was I doing it all wrong all the way?
