Re: [Rails] Search of multiple columns

2012-02-21 Thread Tom Meinlschmidt
IF you really need to search over several columns, use concat() for db columns... like scope :search, labda{|search| where("concat(name, genre, console) like ?", "%#{search}%").presence || all } and then use Model.search('value') tom On Feb 21, 2012, at 16:44 , Roger Patrick wrote: > I am c

[Rails] Search of multiple columns

2012-02-21 Thread Roger Patrick
I am currently writing a search method for my rails applications and at the moment it works fine. I have the following in my game.rb: def self.search(search) if search find(:all, :conditions => ['name LIKE ? OR genre LIKE ? OR console LIKE ?', "%#{search}%", "#{search}", "#{search}"]) else

[Rails] Search of multiple columns

2012-02-21 Thread Christopher Jones
I am currently writing a search method for my rails applications and at the moment it works fine. I have the following in my game.rb: def self.search(search) if search find(:all, :conditions => ['game_name LIKE ? OR genre LIKE ? OR console LIKE ?', "%#{search}%", "#{search}", "#{search}"])