Reputation: 591
I'm using 'form for' to send form information and I have a few categories (in my db, they are boolean). To confirm information about categories I use checkbox. But it is not working and I can't understand why.
<%= form.label :lifehacks, "Lifehacks" %>
<%= form.check_box :lifehacks, :class => 'checkbox-in-create-post' %>
And when I go to console and view created post - category "Lifehacks" is false (what is default value). And it's not changing even if checkbox is checked.
But interesting fact: the same code for other category:
<%= form.label :photos, "Photos" %>
<%= form.check_box :photos, :class => 'checkbox-in-create-post' %>
if checkbox is checked is changing category "Photos" boolean to true.
If you need some addition information - tell me.
Can you tell me where I've made my mistake?
Upvotes: 0
Views: 1304
Reputation: 5528
You forgot to permit the lifehacks
parameter in the controller so is not updated. Look for params.require(something).permit(:photos, etc...)
and add your missing lifehacks
parameter in the list of permitted attributes.
Upvotes: 3