Displaying 1 result from an estimated 1 matches for "matching_profil".
Did you mean:
matching_profiles
2013 Mar 05
4
searching model and has_one association
...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 all users have a
profile, so some of the joins techniques would not work as they would onl...