Rewrites named scopes with ARel queries.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10950 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2012-12-07 17:59:20 +00:00
parent 4896d5c7e8
commit 7222e4012d
12 changed files with 55 additions and 55 deletions
+3 -2
View File
@@ -30,8 +30,9 @@ class Document < ActiveRecord::Base
validates_presence_of :project, :title, :category
validates_length_of :title, :maximum => 60
scope :visible, lambda {|*args| { :include => :project,
:conditions => Project.allowed_to_condition(args.shift || User.current, :view_documents, *args) } }
scope :visible, lambda {|*args|
includes(:project).where(Project.allowed_to_condition(args.shift || User.current, :view_documents, *args))
}
safe_attributes 'category_id', 'title', 'description'