Jared Habeck
Jared Habeck

Reputation: 31

Adding records via check boxes in a nested form

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

Answers (2)

ramigg
ramigg

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

Related Questions