A rigid, readable alternative for defining AR scopes.
gem install scoped
require 'scoped'
Then in your ActiveRecord
models:
class Meme < ActiveRecord::Base
include Scoped
scopes do
sad_keanu { where(name: 'Keanu Reaves') }
end
end
Meme.sad_keanu #=> an ActiveRecord::Relation of Memes!
Requires ActiveRecord >= 3.1.0, <= 4.1.0, tested with Ruby 1.9.3, 2.0.0, and 2.1.0.
bundle exec rspec
- Evan Sherwood: http://github.com/neezer