On Aug 19, 10:17 am, Howl Wong <li...@ruby-forum.com> wrote: > I need SQL : > > SELECT `activities`.* FROM `activities` INNER JOIN `friendships` ON > `activities`.user_id = `friendships`.friend_id WHERE > `friendships`.user_id = 1 > > My User Model code: > > has_many :friendships, :dependent => :destroy > has_many :friends, :through => :friendships > has_many :activities > ############################## > has_many :friends_activities, :foreign_key => :user_id, :class_name => > 'Activity', :through => :friendships, :source => :friend > > Rails3 return: > > ON `activities`.id = `friendships`.friend_id ??! :foreign_key is > ignored > > Why ?!!!!
With has many through you use the :source option to tell it which of the associations of friendships to follow to get to the desired row(s) Fred > -- > Posted viahttp://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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.