I am just adding search to my project to be able to find people by name. but on my db i have first_name
and last_name
but if someone searches for a full name like Joe Doe no result matches
#model
class Person < ActiveRecord::Base
def full_name
(self.first_name + ' ' + self.last_name).titleize
end
end
#controller
class PeoplesController < ApplicationController
expose(:peoples){
if params[:search]
People.where(
"first_name ILIKE ?
OR last_name ILIKE ?
", params[:search], params[:search]
)
else
People.all
end
}
end
Again if someone searches a first_name it comes back with results, last_name it comes back with results but not for a full name
and if i try to add full_name
to the query i get column "full_name" does not exist
Thanks for the help