1

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.

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

That did, I actually looked at that exact screencast but it uses a many-to-many where my app is actually a 1-to-many parent-to-child type relationship. I think I will need to use check_box_tag no matter what to craft my own "names" for passing through. I was hoping rails would just be able to "handle" this via accepts_nested_attributes. Thanks again.
1

Take a look :

http://asciicasts.com/episodes/17-habtm-checkboxes

http://ramblings.gibberishcode.net/archives/rails-has-and-belongs-to-many-habtm-demystified/17

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.