I have an search field for user with autocomplete, it was working but I migrated my database from mySQL to Postgresql but cannot get the concatenate working. When I type a first name or a last name is working but when my user are typing Firstname Lastname (with a space between them) it’s not working anymore and cannot get it working or figure out what to do.
That’s my SQL command :
@users = User.find(:all,:conditions => ['(last_name LIKE ? OR first_name LIKE ? OR (first_name || last_name) LIKE ? OR (last_name || first_name) LIKE ?) AND adult = ?', "%#{params[:term]}%", "%#{params[:term]}%", "%#{params[:term]}%", "%#{params[:term]}%", false])
My issue is here : (first_name || last_name) that will return correct value when the user type FirstNameLastName so the concat works here but when I try to add the space I cannot figure out what is wrong I tried :
(first_name ||' '|| last_name) or (first_name ||" "|| last_name)
But none of these will work I found another thread on stackoverflow but cannot get it working and I don’t understand why…
Thanks,
No idea about Rails but how about