This mailing list is meant for discussion about implementation details of Rails only. You can post support requests to Rails Talk [1] or #rubyonrails on freenode.
[1] http://groups.google.com/group/rubyonrails-talk On Aug 7, 2007, at 2:44, paccator wrote: > > Why has_many doesn't set target for objects in its collection? > > E.g. when > > class Author < ActiveRecord; has_many :posts; end > class Post < ActiveRecord; belongs_to :author; end > > then > > some_author.posts.each {|p| puts p.author.name} > > will require additional queries to fetch author for each post. That said, some_author.posts.find(:all, :include => :author).each { | p| puts p.author.name } will do a JOIN for you. Although that shouldn't be necessary if you put some_author in an instance variable and read it from there. Manfred --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
