aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2008-03-04 09:36:18 -0600
committerJoshua Peek <josh@joshpeek.com>2008-03-04 09:36:18 -0600
commitc179dbfa593522c2f92a674f0841c666ff19769a (patch)
tree5baa1e08bfbf50516b61bc8d3f67bb196fe3531c
parent395b562259ad265418c04077e8f45f6adeaf75dc (diff)
Raise RecordNotFound on find_version.
-rw-r--r--lib/acts_as_versioned.rb11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/acts_as_versioned.rb b/lib/acts_as_versioned.rb
index 63eb68f8c..f6a83b39a 100644
--- a/lib/acts_as_versioned.rb
+++ b/lib/acts_as_versioned.rb
@@ -454,9 +454,14 @@ module ActiveRecord #:nodoc:
def find_version(id, version = nil)
return find(id) unless version
- find_versions(id,
- :conditions => ["#{versioned_foreign_key} = ? AND version = ?", id, version],
- :limit => 1).first
+ conditions = ["#{versioned_foreign_key} = ? AND version = ?", id, version]
+ options = { :conditions => conditions, :limit => 1 }
+
+ if result = find_versions(id, options).first
+ result
+ else
+ raise RecordNotFound, "Couldn't find #{name} with ID=#{id} and VERSION=#{version}"
+ end
end
# Finds versions of a specific model. Takes an options hash like <tt>find</tt>