Replaces find(:first/:all) calls.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10931 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -248,14 +248,16 @@ module ActiveRecord #:nodoc:
|
||||
def self.reloadable? ; false ; end
|
||||
# find first version before the given version
|
||||
def self.before(version)
|
||||
find :first, :order => 'version desc',
|
||||
:conditions => ["#{original_class.versioned_foreign_key} = ? and version < ?", version.send(original_class.versioned_foreign_key), version.version]
|
||||
order('version desc').
|
||||
where("#{original_class.versioned_foreign_key} = ? and version < ?", version.send(original_class.versioned_foreign_key), version.version).
|
||||
first
|
||||
end
|
||||
|
||||
# find first version after the given version.
|
||||
def self.after(version)
|
||||
find :first, :order => 'version',
|
||||
:conditions => ["#{original_class.versioned_foreign_key} = ? and version > ?", version.send(original_class.versioned_foreign_key), version.version]
|
||||
order('version').
|
||||
where("#{original_class.versioned_foreign_key} = ? and version > ?", version.send(original_class.versioned_foreign_key), version.version).
|
||||
first
|
||||
end
|
||||
|
||||
def previous
|
||||
@@ -467,9 +469,9 @@ module ActiveRecord #:nodoc:
|
||||
|
||||
# Finds versions of a specific model. Takes an options hash like <tt>find</tt>
|
||||
def find_versions(id, options = {})
|
||||
versioned_class.find :all, {
|
||||
versioned_class.all({
|
||||
:conditions => ["#{versioned_foreign_key} = ?", id],
|
||||
:order => 'version' }.merge(options)
|
||||
:order => 'version' }.merge(options))
|
||||
end
|
||||
|
||||
# Returns an array of columns that are versioned. See non_versioned_columns
|
||||
|
||||
@@ -30,7 +30,7 @@ task :migrate_from_mantis => :environment do
|
||||
assigned_status = IssueStatus.find_by_position(2)
|
||||
resolved_status = IssueStatus.find_by_position(3)
|
||||
feedback_status = IssueStatus.find_by_position(4)
|
||||
closed_status = IssueStatus.find :first, :conditions => { :is_closed => true }
|
||||
closed_status = IssueStatus.where(:is_closed => true).first
|
||||
STATUS_MAPPING = {10 => DEFAULT_STATUS, # new
|
||||
20 => feedback_status, # feedback
|
||||
30 => DEFAULT_STATUS, # acknowledged
|
||||
@@ -347,7 +347,7 @@ task :migrate_from_mantis => :environment do
|
||||
bug.bug_files.each do |file|
|
||||
a = Attachment.new :created_on => file.date_added
|
||||
a.file = file
|
||||
a.author = User.find :first
|
||||
a.author = User.first
|
||||
a.container = i
|
||||
a.save
|
||||
end
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace :redmine do
|
||||
assigned_status = IssueStatus.find_by_position(2)
|
||||
resolved_status = IssueStatus.find_by_position(3)
|
||||
feedback_status = IssueStatus.find_by_position(4)
|
||||
closed_status = IssueStatus.find :first, :conditions => { :is_closed => true }
|
||||
closed_status = IssueStatus.where(:is_closed => true).first
|
||||
STATUS_MAPPING = {'new' => DEFAULT_STATUS,
|
||||
'reopened' => feedback_status,
|
||||
'assigned' => assigned_status,
|
||||
|
||||
Reference in New Issue
Block a user