summaryrefslogtreecommitdiffstats
path: root/app/controllers/watchers_controller.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2016-04-09 07:54:43 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2016-04-09 07:54:43 +0000
commit933dc946d4ba5d755e93be7fd15271ec9fb717ae (patch)
treed70ef1c1e35580558479e8a27e30b95934840010 /app/controllers/watchers_controller.rb
parent14234eae3948fefddce58cda76c94841f836fb08 (diff)
downloadredmine-933dc946d4ba5d755e93be7fd15271ec9fb717ae.tar.gz
redmine-933dc946d4ba5d755e93be7fd15271ec9fb717ae.zip
Preload project when possible (#5754).
git-svn-id: http://svn.redmine.org/redmine/trunk@15314 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers/watchers_controller.rb')
-rw-r--r--app/controllers/watchers_controller.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/app/controllers/watchers_controller.rb b/app/controllers/watchers_controller.rb
index 488898546..d9f2351d0 100644
--- a/app/controllers/watchers_controller.rb
+++ b/app/controllers/watchers_controller.rb
@@ -131,7 +131,12 @@ class WatchersController < ApplicationController
klass = Object.const_get(params[:object_type].camelcase) rescue nil
return unless klass && klass.respond_to?('watched_by')
- objects = klass.where(:id => Array.wrap(params[:object_id])).to_a
+ scope = klass.where(:id => Array.wrap(params[:object_id]))
+ if klass.reflect_on_association(:project)
+ scope = scope.preload(:project => :enabled_modules)
+ end
+ objects = scope.to_a
+
raise Unauthorized if objects.any? do |w|
if w.respond_to?(:visible?)
!w.visible?