checkbox variable in rails always true -


i have rails app using checkbox on view determine part of if statement runs. thought easy task though response in console after clicking submit button shows both: "adult"=>"0" (when not checked) , "adult"=>"1" (when checked) if try

puts @application.adult 

the console prints true

here's relevant part of .html.haml file...this recent attempt

=simple_form_for( :application, :url => users_partner_acceptance_path( application ), :method => :put ) | f |   .clearfix     .column       =f.input :full_name, label: 'full name', placeholder: 'full name'       .help-block * please enter legal name       =f.input :address_1, label: 'address', placeholder: 'apartment, street'       =f.check_box_tag :adult, inline_label: 'i on 18 years old.', as: :boolean, checked = true       .guardian       =f.input :guardian_full_name, label: 'guardian full name', placeholder: 'full name'       =render 'partner_details_errors', application: application   =f.submit 'show contract', class: 'btn btn-primary', data: { 'text' => 'create contract', 'disabled-text' => 'creating ...' }  

i've tried

{:checked=> true} 

and

checked: true  

instead of

checked = true 

and few others i've tried

=f.check_box :adult  

and

=f.input :adult  

instead of

=f.check_box_tag :adult 

in controller, i'm trying this:

if @application.adult == true   # else   # else end 

any suggestions, appreciated. thanks!

i'm using rails 3.2.12

check_box_tag(name, value = "1", checked = false, options = {})

if adult part of application class, want f.check_box instead of f.check_box_tag. otherwise, should have check_box_tag....

= f.label :adult, "i on 18 years old."

= f.check_box, :adult

can post params hash looks when submitted? fyi don't need if @application.adult == true since if doing that.


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -