I would need a dynamic foreign key. What I mean? When frienships.profile_id = 1, then the foreign key is friend_id, when is frienships.friend_id = 1, the foreign key is profile_id
Im using this, but is not working.
has_many :removed_friends, :foreign_key => "(CASE WHEN friendships.profile_id = #{self.id} THEN friend_id ELSE profile_id END)"
But when it generates the mysql query there is a problem. it doesnt work if is like this:
friendships.(case.... and return friend_id or profile_id)
it must be
profile.id = (case... return frienships.profile_id ou frienships.friend_id)
how may i do this??
thanks very much!