Reputation: 485
I have a model Person and a model Option. Option belongs_to person, and Person has_many options. In the form for creating a new Person I want to be able to add several Options before you save the Person. What is the best way to do this?
Upvotes: 1
Views: 100
Reputation: 758
You might find my question, which was answered, and for which I post more or less complete solution files for, to be of use with nested associations:
Upvotes: 0
Reputation: 3861
It isn't necessarily the best solution, but Ryan Bates' nested_form library makes managing dynamic form elements for associated models quite easy. Easy to install and the usage directions in the README sound like they cover your basic case.
Upvotes: 0
Reputation: 1071
Go for rails casts episode 196 and 197 . they have detailed explation and are the best to implement this kind of functionality
http://railscasts.com/episodes/196-nested-model-form-part-1
http://railscasts.com/episodes/197-nested-model-form-part-2
Upvotes: 1