Skip to content

Instantly share code, notes, and snippets.

@pier-oliviert
Forked from steveklabnik/search.rb
Created October 21, 2013 17:01
Show Gist options
  • Save pier-oliviert/7087208 to your computer and use it in GitHub Desktop.
Save pier-oliviert/7087208 to your computer and use it in GitHub Desktop.
class Foo
has_many :tags
has_many :states
# q is hash: { "tags" => "ruby", "states" => "open" }
def self.search(q)
# wat do?
end
end
# search should return a relation that scopes everything to the terms
# the values 'ruby' and 'open' are in the 'name' attribute of the Tag and State model.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment