Module: ScopedSearch::BackwardsCompatibility
- Defined in:
- lib/scoped_search.rb
Instance Method Summary collapse
-
#searchable_on(*fields) ⇒ Object
Defines fields to search on using a syntax compatible with scoped_search 1.2.
Instance Method Details
#searchable_on(*fields) ⇒ Object
Defines fields to search on using a syntax compatible with scoped_search 1.2
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/scoped_search.rb', line 24 def searchable_on(*fields) = fields.last.kind_of?(Hash) ? fields.pop : {} # TODO: handle options? fields.each do |field| if relation = self.reflections.keys.detect { |relation| field.to_s =~ Regexp.new("^#{relation}_(\\w+)$") } scoped_search(:in => relation, :on => $1.to_sym) else scoped_search(:on => field) end end end |