I am using these versions of gem:
gem 'rails', '4.0.1' gem 'mongoid', '~> 4', github: 'mongoid/mongoid' gem 'devise', '3.2.0'
I am trying to pass a boolean selection to mongoid using this form:
= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| = f.check_box :tos_agreement = t(".do_you_accept_our_toc")
My model looks like this:
class User include Mongoid::Document field :tos_agreement, :type => Boolean
The server log states the following:
Started POST "/da/users" for 127.0.0.1 at 2013-11-13 19:41:32 +0100 Processing by RegistrationsController#create as HTML Parameters: {"utf8"=>"β", "authenticity_token"=>"nyfk//kJtXXM1MMSWln5fTn4P2vzzeP4XzgC3GTT/tk=", "user"=>{"tos_agreement"=>"1"}, "commit"=>"Create", "locale"=>"en"} MOPED: 127.0.0.1:27017 QUERY database=mydb_development collection=users selector={"email"=>" example@gmail.com "} flags=[] limit=-1 skip=0 batch_size=nil fields={:_id=>1} runtime: 0.9030ms
As you can see, "1" is passed from the form, but I also tried with "yes" and "true" .
When I start the console, I see that no logical value has been entered, instead the line has:
2.0.0p247 :001 > User.last => #<User _id: 5283c38563687282c5000000, email: " example@gmail.com ", tos_agreement: "1">
What can I do to insert a boolean?