-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
Labels:None
I'm using Rails 4.0beta1, mongoid from git and Ruby 2.0.
I have this in my User model:
field :admin, type: Boolean, default: false
Problem is checkboxes return a string "0" which is type cast to an integer 0. When an integer 0 is stored for the field, it is treated as true:
[1] pry(main)> user = User.first
[2] pry(main)> user.admin = 123
=> 123
[5] pry(main)> user.admin = 0
=> 0
[6] pry(main)> user.admin?
=> true
Shouldn't Mongoid enforce booleans and not just let you store any integer you want?