Reputation: 31
My form is nested so that a Cart has Products, which can have Features. I wish to be able to add features to products via checkboxes.
Upon submit, rails is creating the Cart record, but failing to use "accepts_nested_attributes_for" to complete the addition of nested records.
My form is very straight forward, and I'm not receiving any errors, it's just ignoring the fields. My fields look like this (within the form helper)
= f.fields_for :feature_line_items do |builder|
= builder.check_box :id
= builder.label :id, "Feature Label"
Thanks in advance, I'm kind of doubting this is even possible, and probably need to rethink my data architecture.
Upvotes: 1
Views: 514
Reputation: 5961
Take a look :
http://asciicasts.com/episodes/17-habtm-checkboxes
http://ramblings.gibberishcode.net/archives/rails-has-and-belongs-to-many-habtm-demystified/17
Upvotes: 1
Reputation: 1305
Try this episode in railscasts. Also I suggest using simple_form gem, it makes forms programming very simple and straight forward.
I hope that helped.
Upvotes: 2