Awesome
validates_presence_of_boolean
If you want to validate the presence of a boolean field (where the real values are true and false), you will want to use
validates_inclusion_of :field_name, :in => [true, false]
. (c) ActiveModel
Not cool.
So:
class User < ActiveRecord::Base
validates :admin, not_nil: true
end
or
class User < ActiveRecord::Base
validates_presence_of_boolean :admin
end
Cool.
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request