diff options
author | Michel Pigassou <mpigassou@zendesk.com> | 2016-07-30 15:19:30 +0200 |
---|---|---|
committer | Michel Pigassou <mpigassou@zendesk.com> | 2016-08-13 12:41:45 -0700 |
commit | cafdbeba9043c25280fb816ec5e554ae2d020f86 (patch) | |
tree | c9904aa5466cabbf8114d012af51b80b1ba13228 /activerecord/lib/active_record | |
parent | 6107a40c0e4d05614493bddf33d5ae8d9ce8a8d2 (diff) | |
download | rails-cafdbeba9043c25280fb816ec5e554ae2d020f86.tar.gz rails-cafdbeba9043c25280fb816ec5e554ae2d020f86.tar.bz2 rails-cafdbeba9043c25280fb816ec5e554ae2d020f86.zip |
When calling association.find RecordNotFound is now raised with the same argument as when we do it in Record.find (primary_key, id and model).
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/relation/finder_methods.rb | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb index 7bf84c2f15..8c85e10389 100644 --- a/activerecord/lib/active_record/relation/finder_methods.rb +++ b/activerecord/lib/active_record/relation/finder_methods.rb @@ -348,15 +348,17 @@ module ActiveRecord def raise_record_not_found_exception!(ids, result_size, expected_size) #:nodoc: conditions = arel.where_sql(@klass.arel_engine) conditions = " [#{conditions}]" if conditions + name = @klass.name if Array(ids).size == 1 - error = "Couldn't find #{@klass.name} with '#{primary_key}'=#{ids}#{conditions}" + error = "Couldn't find #{name} with '#{primary_key}'=#{ids}#{conditions}" + raise RecordNotFound.new(error, name, primary_key, ids) else - error = "Couldn't find all #{@klass.name.pluralize} with '#{primary_key}': " + error = "Couldn't find all #{name.pluralize} with '#{primary_key}': " error << "(#{ids.join(", ")})#{conditions} (found #{result_size} results, but was looking for #{expected_size})" - end - raise RecordNotFound, error + raise RecordNotFound, error + end end private |