Given the following two models:
User (id)
FbFriendCache(user_id,fb_user_id)
I would like to be able to do : @user.facebook_friends
Which would return @users from the user model
I’ve tried:
class User < ActiveRecord::Base
has_many :fb_friends,
:through => :fb_friend_cache,
:foreign_key => "fb_user_id"
But that fails w Could not find the association.
Ideas? Thanks
I am posting this as an answer as I am not able to provide the documentation snippet in comments. Ryan’s solution requires a tweak.
The
foreign_keyproperty is ignored forhas_many :throughassociations. You should usesourceproperty instead.Following solution should work: