named_scope => scope

This commit is contained in:
Jacques Crocker 2010-07-31 23:01:38 -07:00
parent 0607be09ab
commit 07a7cddb2d
4 changed files with 8 additions and 8 deletions

View File

@ -31,10 +31,10 @@ class Page
validates_exclusion_of :slug, :in => Locomotive.config.reserved_slugs, :if => Proc.new { |p| p.depth == 0 }
## named scopes ##
named_scope :latest_updated, :order_by => [[:updated_at, :desc]], :limit => Locomotive.config.lastest_items_nb
named_scope :index, :where => { :slug => 'index', :depth => 0 }
named_scope :not_found, :where => { :slug => '404', :depth => 0 }
named_scope :published, :where => { :published => true }
scope :latest_updated, :order_by => [[:updated_at, :desc]], :limit => Locomotive.config.lastest_items_nb
scope :index, :where => { :slug => 'index', :depth => 0 }
scope :not_found, :where => { :slug => '404', :depth => 0 }
scope :published, :where => { :published => true }
## behaviours ##
liquify_template :joined_parts

View File

@ -16,7 +16,7 @@ class PagePart
validates_presence_of :name, :slug
## named scopes ##
named_scope :enabled, where(:disabled => false)
scope :enabled, where(:disabled => false)
## methods ##

View File

@ -31,8 +31,8 @@ class Site
after_destroy :destroy_in_cascade!
## named scopes ##
named_scope :match_domain, lambda { |domain| { :where => { :domains => domain } } }
named_scope :match_domain_with_exclusion_of, lambda { |domain, site| { :where => { :domains => domain, :_id.ne => site.id } } }
scope :match_domain, lambda { |domain| { :where => { :domains => domain } } }
scope :match_domain_with_exclusion_of, lambda { |domain, site| { :where => { :domains => domain, :_id.ne => site.id } } }
## methods ##

View File

@ -13,6 +13,6 @@ class Project
custom_fields_for :people
custom_fields_for :tasks
named_scope :ordered, :order_by => [[:name, :asc]]
scope :ordered, :order_by => [[:name, :asc]]
end