Haveing a little trouble getting a grasp on mongoid and active record validations.
My Model:
class Project
include Mongoid::Document
field :name
field :public, :type=>Boolean
#validation
validates_acceptance_of :public
end
And In my controller I call:
Project.create!(:name => 'Test Project', :public => false)
But I keep getting an error that says: Public must be accepted.
Any thoughts on why I am getting this error although I am creating an entry with a boolean in the public field?
From the fine manual:
The idea is that they have to check the
:publiccheckbox and that should result in a true value; butfalsebeing a non-true value will fail the validation and the validator will tell you that “Public must be accepted”.Maybe you’re looking for:
The documentation also says:
And the
terms_of_servicerefers to their example. So you could also do this:if you wanted to get an entry in MongoDB that looked like someone slipped past your validations.