]> source.dussan.org Git - redmine.git/commitdiff
Avoid a query if enabled_modules association is already loaded (#15058).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 20 Oct 2013 16:04:04 +0000 (16:04 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 20 Oct 2013 16:04:04 +0000 (16:04 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@12228 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/project.rb

index e2b7a9d9e548c5faa26b4751646b03ffd1a9ff65..d4f29453aaba176aebadffb94fdcee140077b84a 100644 (file)
@@ -961,7 +961,7 @@ class Project < ActiveRecord::Base
 
   def allowed_permissions
     @allowed_permissions ||= begin
-      module_names = enabled_modules.pluck(:name)
+      module_names = enabled_modules.loaded? ? enabled_modules.map(&:name) : enabled_modules.pluck(:name)
       Redmine::AccessControl.modules_permissions(module_names).collect {|p| p.name}
     end
   end