Skip to content

Instantly share code, notes, and snippets.

@jackdempsey
Created June 8, 2010 21:26
Show Gist options
  • Save jackdempsey/430677 to your computer and use it in GitHub Desktop.
Save jackdempsey/430677 to your computer and use it in GitHub Desktop.
# map/reduce conditions with meta_where and rails 3
# syntax explanation at http://github.com/ernie/meta_where
scope :match, lambda { |term| where([:title,:description,:keywords].map{|col| col.matches % "%#{term}%"}.inject(&:|))}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment