What's the significance of named scope in Rails?
问题 Before going for details. Question 1:-- What's the meaning of scope here (ie named **scope )?** what's the benefits of using named scope? Now:- from Agile Development with Rails book:-- class Order < ActiveRecord::Base named_scope :last_n_days, lambda { |days| {:conditions => ['updated < ?' , days] } } named_scope :checks, :conditions => {:pay_type => :check} end Such a named scope would make finding the last week's worth of orders a snap. orders = Orders.last_n_days(7) Scopes can also be