ag
2011-Feb-14 20:01 UTC
Rails3 newbie - Question regarding multiple joins and finder methods
Hello all I''ve encountered a weird difficulty...I wonder what am I doing wrong.. I have three models: User,Assignment,Idea The User has many assignments and each assignments belongs to Idea. I have also defined has many through relations on User (ideas) and on Idea (users) -- through assignments... The database is populated with the needed data.. I am using this to query the models.. @out = User.joins(:ideas,:assignments => [:user,:idea]).includes(:ideas,:assignments => [:user,:idea]).find(1) The result contains a User object with ideas array (has_many) with one Idea object but its empty (all attributes are nil)... It also contains an assignments array (has_many) with one Assignment object but the reference to the Idea (belongs_to) is null.. (user_id,idea_id do exist and have correct value) It is like the join is not performed.. BTW- The console shows that the JOIN is performed. What is wrong? Thanks in advance Afik -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.