model: replace Rails2 "named_scope" to Rails3 "scope"

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9537 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA
2012-04-26 23:51:10 +00:00
parent 71649ba2f1
commit d0d01d4e70
19 changed files with 49 additions and 47 deletions
+4 -4
View File
@@ -24,9 +24,9 @@ class Principal < ActiveRecord::Base
has_many :issue_categories, :foreign_key => 'assigned_to_id', :dependent => :nullify
# Groups and active users
named_scope :active, :conditions => "#{Principal.table_name}.status = 1"
scope :active, :conditions => "#{Principal.table_name}.status = 1"
named_scope :like, lambda {|q|
scope :like, lambda {|q|
if q.blank?
{}
else
@@ -44,7 +44,7 @@ class Principal < ActiveRecord::Base
}
# Principals that are members of a collection of projects
named_scope :member_of, lambda {|projects|
scope :member_of, lambda {|projects|
projects = [projects] unless projects.is_a?(Array)
if projects.empty?
{:conditions => "1=0"}
@@ -54,7 +54,7 @@ class Principal < ActiveRecord::Base
end
}
# Principals that are not members of projects
named_scope :not_member_of, lambda {|projects|
scope :not_member_of, lambda {|projects|
projects = [projects] unless projects.is_a?(Array)
if projects.empty?
{:conditions => "1=0"}