Permalink
Browse files

Merge pull request #26598 from rutaka-n/raise_record_not_found_with_c…

…orrect_params

initialize errors with name of class and other params
  • Loading branch information...
eileencodes committed Oct 15, 2016
2 parents be6990b + 02bcd71 commit d80611d32084c86f72226907099c09f2709d667f
Showing with 2 additions and 2 deletions.
  1. +2 −2 activerecord/lib/active_record/relation/finder_methods.rb
@@ -353,15 +353,15 @@ def raise_record_not_found_exception!(ids = nil, result_size = nil, expected_siz
if ids.nil?
error = "Couldn't find #{name}"
error << " with#{conditions}" if conditions
- raise RecordNotFound, error
+ raise RecordNotFound.new(error, name)
elsif Array(ids).size == 1
error = "Couldn't find #{name} with '#{primary_key}'=#{ids}#{conditions}"
raise RecordNotFound.new(error, name, primary_key, ids)
else
error = "Couldn't find all #{name.pluralize} with '#{primary_key}': "
error << "(#{ids.join(", ")})#{conditions} (found #{result_size} results, but was looking for #{expected_size})"
- raise RecordNotFound, error
+ raise RecordNotFound.new(error, name, primary_key, ids)
end
end

0 comments on commit d80611d

Please sign in to comment.