Niklas Nson
2012-Nov-27 06:33 UTC
Active record queries, reverse lookup on has_many: :through =>
*User.rb* has_many :looking_for_whos, :class_name => "UserLookingForWho" has_many :asset_looking_for_whos, :through => :looking_for_whos belongs_to :asset_usertype In a controller i can do the following: *@users = User.where(asset_usertype_id: [current_user.looking_for_who_ids])* to get all users who''s *asset_user_type_id* is in *looking_for_who_ids*, but the trick i would like to add a reverse lookup as well; to maker sure that Users selected *also* is looking for the current_user.asset_usertype_id. But i cant get my head around what to do, someone who could give me some pointers ? -- 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/ZSLeVWhehMkJ. For more options, visit https://groups.google.com/groups/opt_out.