RangeError for simple integer assignment in Rails 4.2.0 that should be caught by validation

余生长醉 提交于 2019-12-05 00:28:51

Get the latest rails version to fix this error, it was recently fixed by Sean Griffin

To do that before a version comes out, remove the specific version in your gemfile and use the git location hint :

gem 'rails', :git => 'https://github.com/rails/rails.git'

You can force your migration file to use a BigInt. I had the same problem but I am not using Rails but just ActiveRecord. This will solve your bug:

t.integer :really_big_int, limit: 8

If you have a single validation, then upgrading to Rails 4.2.1 does the trick. However, if you've got multiple validations, such as also validating uniqueness, you have to upgrade to a more recent version than 4.2.1. I upgraded to 4.2.3. I don't know whether 4.2.2 works or not.

In my case this also happens on simple where(some_id: BIG_NUMBER_HERE). I wouldn't describe it as expected, this should rather result in ActiveRecord::RecordNotFound

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!