How to change the default value of check_box ?
views/doctors/_form.html.erb
<%= form_for(@doctor) do |f| %>
<%= f.label :pass %><br>
<%= f.check_box :pass, {checked: true, checked_value: "yes", unchecked_value: "No"} %>
<%= f.submit %>
<% end %>
The data type of :pass attribute was string
, But still it was not created any value for :pass
attribute in DB. So, I changed the data type of :pass attribute into boolean.
Now it is working with True and False
But, I Just want to change the True and False
into Yes and No
Please someone help me.
According to this, the correct syntax is:
check_box(object_name, method, options = {}, checked_value = "1", unchecked_value = "0")
So, you should change your code to this:
<%= f.check_box :pass, { checked: true }, '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