RailsCasts Pro episodes are now free!

Learn more or hide this

GabesStudio's Profile

GitHub User: gabekessler

Comments by GabesStudio

Avatar

In case someone's still looking for an easy answer to searching in multiple attributes, you can set it up like the where params in scopes:

def self.search(search)
 if search
  find(:all, :conditions => ['first_name LIKE ? || last_name LIKE ? || company_name LIKE ?', "%#{search}%", "%#{search}%", "%#{search}%"])
 else
  find(:all)
 end
end