Dusty Boshoff
Dusty Boshoff

Reputation: 1061

inter-model creations

I have 4 models, Software, Hardware, Support and Location. I used a scaffold to create them all along with their attributes which are mostly all strings.

My question is, when I call new_softwares_path it renders a view called new.html.erb which calls _form.html.erb which was created by the scaffold, this view as you know auto creates the form_for with text_field's and text_area's section's for the attributes listed in the software model.

I want to know, how can I call the hardware model attributes from the software's _form.html.erb view and have then be created with the software attributes? I have setup the relationships between the models, but just need help calling the attributes in a inter-model view fashion. .

Upvotes: 0

Views: 22

Answers (1)

zachar
zachar

Reputation: 1095

I think that nested attributes are solution for you. Ryan Bates explained it quite good in one of his railscasts:

http://railscasts.com/episodes/196-nested-model-form-part-1

Upvotes: 1

Related Questions