diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2019-03-30 05:07:07 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-30 05:07:07 +0900 |
commit | 406d3a926cfcd3724f8002f70346aad95eed4a8c (patch) | |
tree | 904c27fe5180b587847ebbe1832d1e165202ef4f /activemodel/lib | |
parent | 7f11fe4570679375c4a4e3c1d712589928440d10 (diff) | |
parent | 2d12f800f1c6b0a2018346e0139301070273e46f (diff) | |
download | rails-406d3a926cfcd3724f8002f70346aad95eed4a8c.tar.gz rails-406d3a926cfcd3724f8002f70346aad95eed4a8c.tar.bz2 rails-406d3a926cfcd3724f8002f70346aad95eed4a8c.zip |
Merge pull request #35794 from kamipo/type_cast_symbol_false
Type cast falsy boolean symbols on boolean attribute as false
Diffstat (limited to 'activemodel/lib')
-rw-r--r-- | activemodel/lib/active_model/type/boolean.rb | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/activemodel/lib/active_model/type/boolean.rb b/activemodel/lib/active_model/type/boolean.rb index f6c6efbc87..e64d2c793c 100644 --- a/activemodel/lib/active_model/type/boolean.rb +++ b/activemodel/lib/active_model/type/boolean.rb @@ -14,7 +14,16 @@ module ActiveModel # - Empty strings are coerced to +nil+ # - All other values will be coerced to +true+ class Boolean < Value - FALSE_VALUES = [false, 0, "0", "f", "F", "false", "FALSE", "off", "OFF"].to_set + FALSE_VALUES = [ + false, 0, + "0", :"0", + "f", :f, + "F", :F, + "false", :false, + "FALSE", :FALSE, + "off", :off, + "OFF", :OFF, + ].to_set.freeze def type # :nodoc: :boolean |