How are values cast when assigning to a Boolean field in Rails ActiveRecord?

前端 未结 3 1311
醉酒成梦
醉酒成梦 2021-02-08 21:37

Short version of my question

In Rails ActiveRecord, if I have a Boolean field and I assign it something like \"abc\" or 2, the

3条回答
  •  你的背包
    2021-02-08 22:16

    This is a Ruby thing rather than a Rails thing. Boolean is "truthy". There's a pretty useful article on it here. https://gist.github.com/jfarmer/2647362

提交回复
热议问题