scope(name, body, &block)
Instance Public methods
Adds a class method for retrieving and querying objects. A scope represents a narrowing of a database
query, such as where(color:
:red).select('shirts.*').includes(:washing_instructions).
class Shirt < ActiveRecord::Base
scope :red, -> { where(color: 'red') }
scope :dry_clean_only, -> { joins(:washing_instructions).where('washing_instructions.dry_clean_only = ?', true) }
end
The above calls to scope define class me