Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More intuitive support for making Boolean's required.
validates_presence_of :field doesn't work for a Boolean field because false is considered blank. Instead you have to use validates_inclusions_of :field, :in => [true, false]. This is a known annoyance of AR. We can make this better in MongoMapper by having the :required shortcut do the right thing. So if you do: key :field, String, :required => true Then it does a validates_presence_of :field. But if you do: key :flag, Boolean, :required => true It does a validates_inclusion_of :field, :in => [true, false]
- Loading branch information