diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-12-03 18:21:32 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-12-03 18:21:32 +0000 |
commit | 31c33f462d92aead29b8feb6445d8fe5626c4963 (patch) | |
tree | 0818c626e553e1cbb606e9c23a7342583288d448 /app/models/project.rb | |
parent | 013c6fe009e74892659c64c2936a2668a9663985 (diff) | |
download | redmine-31c33f462d92aead29b8feb6445d8fe5626c4963.tar.gz redmine-31c33f462d92aead29b8feb6445d8fe5626c4963.zip |
Replaces find(:first) calls.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10928 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/project.rb')
-rw-r--r-- | app/models/project.rb | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index 5a8ba855b..174f63c3a 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -308,9 +308,12 @@ class Project < ActiveRecord::Base # Check that there is no issue of a non descendant project that is assigned # to one of the project or descendant versions v_ids = self_and_descendants.collect {|p| p.version_ids}.flatten - if v_ids.any? && Issue.find(:first, :include => :project, - :conditions => ["(#{Project.table_name}.lft < ? OR #{Project.table_name}.rgt > ?)" + - " AND #{Issue.table_name}.fixed_version_id IN (?)", lft, rgt, v_ids]) + if v_ids.any? && + Issue. + includes(:project). + where("#{Project.table_name}.lft < ? OR #{Project.table_name}.rgt > ?", lft, rgt). + where("#{Issue.table_name}.fixed_version_id IN (?)", v_ids). + exists? return false end Project.transaction do @@ -655,7 +658,7 @@ class Project < ActiveRecord::Base # Returns an auto-generated project identifier based on the last identifier used def self.next_identifier - p = Project.find(:first, :order => 'created_on DESC') + p = Project.order('created_on DESC').first p.nil? ? nil : p.identifier.to_s.succ end |