Nested form using accepts_nested_attributes_for with pre-population from another table
Posted
by mikeydelamonde
on Stack Overflow
See other posts from Stack Overflow
or by mikeydelamonde
Published on 2010-04-14T14:56:03Z
Indexed on
2010/04/15
1:43 UTC
Read the original article
Hit count: 300
ruby-on-rails
|nested-forms
I'm using Rails 2.3.5 and have a nested structure as follows:
Lists has_many Items
Items_Features has_many Features
Items_Features has_many Items
Items_Features has a text field to hold the value of the feature
Then I have a nested form with partials to update and display this so that it updates Lists, Items and Items_Features
What I want to do is generate input fields for each of the rows in features so that the user can fill in a value and it gets inserted/updated in items_features. I also want a label next to the box to display the feature name.
It might look like this:
List name: Cheeses
Item1 name: Edam
Feature, hardness: - fill in - <= this list of features from feature table
Feature, smell: - fill in -
How can I interrupt the nice and easy accepts_nested_attributes_for system to display this as I want?
© Stack Overflow or respective owner