Changed behavior of boolean columns in ActiveRecord 5
When writing specs for the validation of booleans in the list model, https://git.codecoop.org/schleuder/schleuder3/blob/master/lib/schleuder/list.rb#L27 i stumbled across the following issue. Schleuder currently uses ActiveRecord ~> 4.1, which casts all of the following values to false:
FALSE_VALUES = [false, 0, '0', 'f', 'F', 'false', 'FALSE', 'off', 'OFF'].to_set
If i run the specs when assigning "foobar" to a boolean column i receive the following error message:
DEPRECATION WARNING: You attempted to assign a value which is not explicitly
true
orfalse
("foobar") to a boolean column. Currently this value casts tofalse
. This will change to match Ruby's semantics, and will cast totrue
in Rails 5. If you would like to maintain the current behavior, you should explicitly handle the values you would like cast tofalse
. (called from block (2 levels) in <top (required)> at /Users/sssggr/projects/schleuder3/spec/schleuder/list_spec.rb:91)
The new behaviour was introduced with these commits
- https://github.com/rails/rails/commit/e01a46f1f0e21d9018906a6a8dcfdae2d92f32ae
- https://github.com/rails/rails/commit/a502703c3d2151d4d3b421b29fefdac5ad05df61
The initial question for me is: Does it make sense to upgrade to ActiveRecord 5?
If not: Since we know already that the behaviour will change in the very near future, should the values be casted to true explicitly?