Someone wrote here that nil :include results are cached with has_one
association in edge rails. I can''t get edge rails at the moment, so
could anybody answer please if nil results are cached with belongs_to
associations. This means that when u perform find with :include =>
belongs_to_association and the result of generated LEFT OUTER JOIN is
nil, rails doesn''t generate sql query SELECT * FROM
when using method found_object.belongs_to_association
At the moment I have to use query like this in my model to get the same
result:
def self.get_associations( id, association )
find( :all,
:joins => "JOIN #{association} ON #{association}.key =
model_table._key",
:include => association,
:conditions => [ "model_table.key =
''?''", id ],
)
end
And I have to run it in a iteration for each association instead of
selecting all associations in one query :((
Thanks,
Dmitry
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---