Reputation: 650
I want to submit false as a default value for rails form while submitting it.
But however after submitting i am getting null as a default value.
The code is below
<%= f.check_box :known, {}, "false" %>
The column name is known for the table name notes
Can anyone help me on this please?
Upvotes: 1
Views: 2992
Reputation: 33542
As suggested by @Jon, If you always want false
as the default value, you should set it as the default value in the database. The below migration code does that.
change_column :notes, :known, :boolean, default: false
And if you want to give the user an option to change it to true, then specify the check_box
like below.
<%= f.check_box :known, {}, "true", "false" %>
Upvotes: 4