I am going crazy handling checkboxes in rails.
I have Yes,No check_box_tag in rails which are not working correctly becuase data is not being persisted correctly.
e.g when I uncheck a box, it should save null/empty/nil in database.
<label>
<%= check_box_tag "user[credit_report_available]", 1, @user.credit_report_available == 1 ? true : nil, id: "user_credit_report_available" %>
<span class="btn <%= 'active' if (@user.credit_report_available) %>"> Yes </span>
</label>
<label>
<%= check_box_tag "user[credit_report_available]", 0, @user.credit_report_available == 0 ? false : nil, id: "user_credit_report_available" %>
<span class="btn <%= 'active' if (@user.credit_report_available == 0) %>"> No </span>
</label>
Aucun commentaire:
Enregistrer un commentaire