I have a model that contains a :boolean field. In my view, I have a
simple select of Yes or No, which equates to true or false,
respectively. If I choose yes and save, everything works great. If I
choose no, my model fails validation as I have this set as a required
field using validates_presence_of. I have checked the log and it’s
definitely set to false, why would this fail validation?
It basically says that due to some other bits of AR magic, you have to
validate_presence_of kind of funky on boolean variables:
validates_inclusion_of :field_name, :in => [true, false]
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.