diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2016-06-01 04:00:05 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2016-12-06 21:30:25 +0900 |
commit | 49edce37f92b1dcad4b67b3eb35922e7cec88726 (patch) | |
tree | eaf97037eb42a02eceefef408cfc13418e67cc47 /activerecord/lib/active_record/relation | |
parent | cf6c2948d5e0e0d40a03f6858179a659a0a6ed7a (diff) | |
download | rails-49edce37f92b1dcad4b67b3eb35922e7cec88726.tar.gz rails-49edce37f92b1dcad4b67b3eb35922e7cec88726.tar.bz2 rails-49edce37f92b1dcad4b67b3eb35922e7cec88726.zip |
Translate numeric value out of range to the specific exception
Raise `ActiveRecord::RangeError` when values that executed are out of range.
Diffstat (limited to 'activerecord/lib/active_record/relation')
-rw-r--r-- | activerecord/lib/active_record/relation/finder_methods.rb | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb index 93c8722aa3..5e456452e9 100644 --- a/activerecord/lib/active_record/relation/finder_methods.rb +++ b/activerecord/lib/active_record/relation/finder_methods.rb @@ -76,7 +76,7 @@ module ActiveRecord # Post.find_by "published_at < ?", 2.weeks.ago def find_by(arg, *args) where(arg, *args).take - rescue RangeError + rescue ::RangeError nil end @@ -84,7 +84,7 @@ module ActiveRecord # an ActiveRecord::RecordNotFound error. def find_by!(arg, *args) where(arg, *args).take! - rescue RangeError + rescue ::RangeError raise RecordNotFound.new("Couldn't find #{@klass.name} with an out of range value", @klass.name) end @@ -333,7 +333,7 @@ module ActiveRecord end connection.select_value(relation, "#{name} Exists", relation.bound_attributes) ? true : false - rescue RangeError + rescue ::RangeError false end @@ -458,7 +458,7 @@ module ActiveRecord else find_some(ids) end - rescue RangeError + rescue ::RangeError raise RecordNotFound, "Couldn't find #{@klass.name} with an out of range ID" end |