Forum: Ruby on Rails Nested models and forms

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
8d295740bdc6fecc406cff2e8b895f48?d=identicon&s=25 Sahil Dave (Guest)
on 2009-06-01 11:18
(Received via mailing list)
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

<div id="job_profiles">
   <%= render(:partial => 'job_profile', :locals => { :f => f,
:job_profile => @vacancy.job_profiles.build }) %>
</div>
<p>
   <%= add_job_profile_link("Add a job profile", f, @vacancy) %>
</p>

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
This topic is locked and can not be replied to.