This is a query run very infrequently (as admin), and it's not worth indexing/ using up RAM with sphinx.
So, with the variables set up something like this: fn, ln, em = 'John', 'Smith', '[email protected]'
The query is something like this:
profiles = Profile.joins(:user).where(:users=>{"email" => em}).
where("first_name LIKE '%#{fn}%' AND last_name LIKE '%#{ln}%'")
Except that I want the email to accept a substring (e.g. if em == 'th@gm', then it should match '[email protected]'). How do you write this to do a join selecting only those users with a variable matching a regex?