Module: Searchable::ActiveRecord::InstanceMethods
- Defined in:
- lib/searchable.rb
Instance Method Summary collapse
Instance Method Details
#search(options = {}) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/searchable.rb', line 11 def search( = {}) case search_method() when :string self.where(["#{@field} LIKE ?", "%#{[:by]}%"]) when :letter self.where(["#{@field} LIKE ?", "#{[:by_letter]}%"]) when :numbers self.where(["#{@field} RLIKE ?", '^[0-9]']) else self.where(1) end end |