# Nested models and forms

**URL:** <https://www.ruby-forum.com/t/nested-models-and-forms/169243>\
**Category:** Rails\
**Created:** [June 1, 2009, 11:18am UTC](https://www.ruby-forum.com/t/nested-models-and-forms/169243 "2009-06-01T11:18:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sahil\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ee7513/32.png) [@Sahil\_D](https://www.ruby-forum.com/u/Sahil_D)\
**Post date:** [June 1, 2009, 11:18am UTC](https://www.ruby-forum.com/t/nested-models-and-forms/169243/1 "2009-06-01T11:18:30Z")

</div>

Hi,

I have been trying to use the new nested models & forms feature in rails  
2.3

#helper

def add\_job\_profile\_link(name, form, vacancy)  
link\_to\_function name do |page|  
profile = render(:partial =\> ‘job\_profile’, :locals =\> { :f =\>  
form, :job\_profile =\> vacancy.job\_profiles.build })  
page \<\< %{  
$(‘job\_profiles’).insert({ bottom: “#{ escape\_javascript profile  
}”});  
}  
end  
end

#view

 \<%= render(:partial =\> 'job\_profile', :locals =\> { :f =\> f, :job\_profile =\> @vacancy.job\_profiles.build }) %\>

\<%= add\_job\_profile\_link("Add a job profile", f, @vacancy) %\>

The above code is displaying the fields, but on submission picks up  
values  
for just 2 nested models. I tried removing the default rendered partial,  
and  
then it picks up just 1 set of values.  
Am i doing something wrong over here?  
Does @vacancy.job\_profiles.build has different meanings in view and  
helper?

Regards

–  
Sahil
