Skip to content

Instantly share code, notes, and snippets.

@danieljohnmorris
Forked from ecin/search_scope.rb
Created March 26, 2013 03:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danieljohnmorris/5242973 to your computer and use it in GitHub Desktop.
Save danieljohnmorris/5242973 to your computer and use it in GitHub Desktop.
class Address
# :street, String
# :city, String
# :state, String
# :country, String
scope :local, lambda { |query| search_by_street_or_city(query, query) }
scope :national, lambda {|query| search_by_state_or_country(query, query) }
end
Address.national("Iceland") # => [<Address ...>]
Address.local("Iceland") # => []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment