summaryrefslogtreecommitdiffstats
path: root/lib/plugins
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-12-03 21:30:10 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-12-03 21:30:10 +0000
commitea296a109a8655ea48c02c1d0a9bb0d19002d236 (patch)
tree08b5e517e77e341cfdd5a23d649dd1e754074dd4 /lib/plugins
parenta7023dfa9b8e39e6e0a73e57d22823e8a4260b71 (diff)
downloadredmine-ea296a109a8655ea48c02c1d0a9bb0d19002d236.tar.gz
redmine-ea296a109a8655ea48c02c1d0a9bb0d19002d236.zip
Replaces find(:first/:all) calls.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10931 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib/plugins')
-rw-r--r--lib/plugins/acts_as_versioned/lib/acts_as_versioned.rb14
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/plugins/acts_as_versioned/lib/acts_as_versioned.rb b/lib/plugins/acts_as_versioned/lib/acts_as_versioned.rb
index 3c09310f5..b63c891e4 100644
--- a/lib/plugins/acts_as_versioned/lib/acts_as_versioned.rb
+++ b/lib/plugins/acts_as_versioned/lib/acts_as_versioned.rb
@@ -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