ruby - RangeError for simple integer assignment in Rails 4.2.0 that should be caught by validation -
* Update: now fixed in 4.2.stable and 4.2.1 *
In Rail 4.2.0 (and current 4.2.stable), Sure_in_arange method occurs before AR verification, a RangeError
generates something simple in the form of a postgrace type integer column
@ obj.threshold = 10_000_000_000 < / P>
threshold Integer | This yields
RangeError: 10000000000 ActiveRecord :: Connection Adapter :: PostgreSQL :: OID :: The range for integer is out of bounds. /2.0.0-p598/lib/ruby/gems/2.0.0/bundler/gems/rails-62e9e61f2d1b/activerecord/lib/active_record/type/integer.rb41:in `sure_in_arange '
That's true! But users have an ActiveRecord model recognition such as
Valid: threshold, presence: true, numeracy: {big_than_or_equal_to: 0, low_than: 1_000_000} I can not imagine that this is the behavior of behavior, someone has an explanation why this type of cast occurs before verification?
Get the latest Rail version,
version to correct this error To do this before the arrival, remove the specific version in your gemfile and use the git location signal:
gem 'rails',: git = & gt; 'Http://github.com/rails/rails.git'
Comments
Post a Comment