Q:

Using Concat within a Rails Scope

I have a Contact model.  It has the attributes: first_name and last_name.  The user enters text in a search field with the prompt: Enter the contact's full name.  Rails then needs to find all contact records LIKE the name entered.
Here is a picture of the contact records:

-If the user types in "JOE" then rails will return two records (because it is case insensitive)
-If the user types in "joe s" then rails will return two records
-If the user types in "doe" then rails will return one record.
#models/contact.rb
class Contact < ActiveRecord::Base
  scope :by_entered_name, -> (full_name){where("CONCAT('first_name',' ','last_name') LIKE ?", full_name)}
end

Generated sql when I run Contact.by_entered_name("joe") in the rails console:
SELECT "contacts".* FROM "contacts" WHERE (CONCAT('first_name',' ','last_name') LIKE 'joe'

I am using mysql in case that detail is important. For this example app however, I am using sqlite, and it is throwing a syntax error.  Ultimately what is most important is that I get this to work on mysql.
Update: It was expressed that my question was not clear.  My question is: 
How do I properly create a query which takes text entered by a user, and finds all contacts whose concatenated first_name and last_name are LIKE that submitted text by the user?  I also need it to be case insensitive.  My attempted scope above does not appear to work.

A:

There are some quotes in there you don't need.  And you need the wildcard % in the parameter.  Also, ILIKE is needed to disregard the case with Postgres.
class Contact < ActiveRecord::Base
  scope :by_entered_name, -> (full_name){where("CONCAT(first_name,' ',last_name) ILIKE ?", "%#{full_name}%")}
end

