I am trying to query the database as such because of a rails3-jquery-autocomplete gem as talked about in this question Rails gem rails3-jquery-autocomplete: How do I query multiple fields
User.select("first_name, last_name, login, id").where(["CONCAT_WS(' ', first_name, last_name, login) LIKE ?", "%#{parameters[:term]}%"])
This works fine for what I need it to do but I feel like having explicit MYSQL code within my rails app is dirty and I was wondering if there was a database agnostic way of formulating the above query? If not is there a database that doesn't suport some sort of concatenate function?
I can't use a virtual attribute because the gem needs to query the database.
Alternatively I was going to add an extra column called full_name to the User model itself and use virtual attributes to separate it into first_name and last_name but would prefer another solution.