Rails: foreign_key that is set with a CASE WHEN mysql statement
- by user305270
belongs_to :removed_friend,
:class_name => 'Profile',
:foreign_key => "(CASE WHEN friendships.profile_id = #{self.id} THEN friendships.friend_id ELSE friendships.profile_id END)"
The self.id its not working too :s it should be the id of the profile that is triggered the action.
Anyway the main problem is that this foreign_key is not working and i got a mysql error.
please help.. thanks