RailsCasts Pro episodes are now free!

Learn more or hide this

rubyonrails3's Profile

GitHub User: rubyonrails3

Comments by


Hey Ryan, I was trying this with rails 3.1.3

has_many :friendships
has_many :friends, :through => :friendships

and it says to set source =>

can you help how we can control join table on condition

SELECT `users`.* FROM `users` WHERE `users`.`id` = 2 LIMIT 1
  User Load (0.2ms)  SELECT `users`.id FROM `users` INNER JOIN `friendships` ON `users`.`id` = `friendships`.`user_id` WHERE `friendships`.`friend_id` = 2

any guess how i can change this to

friendships` ON `users`.`id` = `friendships`.`friend_id` 

Thanks :-)