sexy_scope is a small wrapper around Arel::Attribute that adds a little syntactic sugar when creating scopes in ActiveRecord. It adds an attribute class method which takes an attribute name and returns an Arel::Attribute wrapper, which responds to common operators to return predicates objects that can be used as arguments to ActiveRecord::Base.where.

class Product < ActiveRecord::Base
  scope :untitled, where(attribute(:name) == nil)
 
  def self.cheaper_than(price)
    where attribute(:price) < price
  end
 
  def self.search(term)
    where attribute(:name) =~ "%#{term}%"
  end
end

sexy_scope reimplements Arel attribute methods like lt, in, matches and not using regular Ruby operators.

source: http://github.com/samleb/sexy_scopes