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
+2 -4
View File
@@ -168,10 +168,8 @@ class Query < ActiveRecord::Base
user = args.shift || User.current
base = Project.allowed_to_condition(user, :view_issues, *args)
user_id = user.logged? ? user.id : 0
{
:conditions => ["(#{table_name}.project_id IS NULL OR (#{base})) AND (#{table_name}.is_public = ? OR #{table_name}.user_id = ?)", true, user_id],
:include => :project
}
includes(:project).where("(#{table_name}.project_id IS NULL OR (#{base})) AND (#{table_name}.is_public = ? OR #{table_name}.user_id = ?)", true, user_id)
}
def initialize(attributes=nil, *args)