aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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>