rails/rails — pull request #5948 by jacobo (2012-04-24 01:40:13+00:00)
Title: Expose Arel predicates as extensions to symbol (like DataMapper)

It's incredibly annoying to negate things in Active Record! I can do:

Person.where(:name => "Jacob")

but to negate it, I'd have to use a SQL fragment like this:

Person.where("name <> ? ", "Jacob")

I want support:

Person.where(:name.not => "Jacob")

This is inspired by the DataMapper way (http://datamapper.org/docs/find.html)

It turns out Arel actually has a LOT of predicates that are not exposed by Active Record. So why not expose them all? (see: https://github.com/brynary/arel/blob/master/lib/arel/predications.rb)

Examples of using predicates directly defined by arel:

Person.where(:name.matches => "%opher")
Person.where(:age.gt => 10)

Examples of the special "not" predicate:

Person.where(:name.not => nil)
Person.where(:name.not => ["Jacob","Micah"])