diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2016-08-16 05:36:18 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-16 05:36:18 -0300 |
commit | caef3b92149c2f73536110ec0ef582b43e48329c (patch) | |
tree | 07b00a2a3e5916067861e63a4e324e50aab6a6da /activerecord/lib/active_record | |
parent | 1a52ed178423dd727653c31398045993cd8c8cb8 (diff) | |
parent | cafdbeba9043c25280fb816ec5e554ae2d020f86 (diff) | |
download | rails-caef3b92149c2f73536110ec0ef582b43e48329c.tar.gz rails-caef3b92149c2f73536110ec0ef582b43e48329c.tar.bz2 rails-caef3b92149c2f73536110ec0ef582b43e48329c.zip |
Merge pull request #26097 from Dagnan/fix_recordnotfound_args_rebased
When calling association.find RecordNotFound is now raised with the s…
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 a99e000616..d46b4e0683 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 |