<%= f.check_box:TYPE %> AB <br><br>
I have used the above mentioned in my code and when i click submit it takes 1
if checked
and 0
if not checked
and it is stored in db
. How can i store a string
like AB
if checked
and nil
if not checked
and i want to store that string in db
instead of 0 and 1
?
This is the definition of this helper method:
check_box (object_name, method, options = {}, checked_value = "1", unchecked_value = "0")
So I supose you need something like:
<%= check_box :type, {}, "AB", "nil" %> AB <br><br>
But in your rails application you get string 'AB'
and string 'nil'
, that how it works.
Rails 3.2 @ http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html check_box(object_name, method, options = {}, checked_value = "1", unchecked_value = "0")
ex. <%= f.check_box( :type, {}, "yes", "no") %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With