Sunday, April 25, 2010

[Rails] Rails3: ActiveRecord includes(:relation) not working

Hey everyone,

i can't build AR-Queries with relationships between tables. Here's a
short sample:

class Customer < ActiveRecord::Base
has_many :projects
end
class Project < ActiveRecord::Base
belongs_to :customer
end
When I execute the following Code in my Controller: @customers =
Customer.all.includes(:projects)
a NoMethodError (undefined method `includes' for #<Array:0xb679e030>)
is thrown.

Why did i receive an Array and not an Object of the class
ActiveRecord?

Thanks in advance for your help!

Greets, Gerrit

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate