Skip to content

Instantly share code, notes, and snippets.

@mikebannister
Created September 20, 2011 12:54
Show Gist options
  • Save mikebannister/1229005 to your computer and use it in GitHub Desktop.
Save mikebannister/1229005 to your computer and use it in GitHub Desktop.
scope :search, lambda { |field, value|
return where(field, Product.gender_database_param(value)) if field == :gender
return where(field, Product.status_database_param(value)) if field == :status
where(field, value)
}
Product.search(gender: 'male').search(brand: 'whatever')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment