From: Jean-Philippe Lang Date: Sat, 13 Sep 2008 10:37:23 +0000 (+0000) Subject: Replaces repository_enable named scope on Project with a more generic one: has_module. X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=231e98f0c75819470dddcca0bdf9e1768ac3e2e8;p=redmine.git Replaces repository_enable named scope on Project with a more generic one: has_module. The new named scope uses raw sql condition to avoid enabled_modules association loading. git-svn-id: http://redmine.rubyforge.org/svn/branches/nbc@1805 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/app/controllers/sys_controller.rb b/app/controllers/sys_controller.rb index b6ad83d04..395683886 100644 --- a/app/controllers/sys_controller.rb +++ b/app/controllers/sys_controller.rb @@ -24,7 +24,7 @@ class SysController < ActionController::Base # Returns the projects list, with their repositories def projects_with_repository_enabled - Project.repository_enabled(:all, :include => :repository, :order => 'identifier') + Project.has_module(:repository).find(:all, :include => :repository, :order => 'identifier') end # Registers a repository for the given project identifier diff --git a/app/models/project.rb b/app/models/project.rb index a51c08681..e40af9967 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -63,7 +63,7 @@ class Project < ActiveRecord::Base before_destroy :delete_all_members - named_scope :repository_enabled, { :include => :enabled_modules, :conditions => ["#{EnabledModule.table_name}.name=?", 'repository'] } + named_scope :has_module, lambda { |mod| { :conditions => ["#{Project.table_name}.id IN (SELECT em.project_id FROM #{EnabledModule.table_name} em WHERE em.name=?)", mod.to_s] } } def identifier=(identifier) super unless identifier_frozen?