search for: matching_users

Displaying 1 result from an estimated 1 matches for "matching_users".

2013 Mar 05
4
searching model and has_one association
Howdy. I have these models: User, field "mundane_name" user has_one :instructor_profile (may or may not exist) instructor_profile, field "sca_name" belongs_to :user I would like to craft a search on these fields, which is effectively this, but in one go: matching_users = User.where("mundane_name ILIKE ?", "%#{target}%") matching_profiles = InstructorProfile.where("sca_name ILIKE ?", "%#{target}%").map(&:user) (matching_users + matching_profiles).uniq However, I''m having problems formulating the query. Not al...