I've been following this railscast http://media.railscasts.com/videos/074_complex_forms_part_2.mov
I've got a task and steps. Each task can have many steps.
I'm attempting to add a nested form by clicking a link. the difference between what the railscast shows, and what I have is that i've got my steps form in my steps controller, but that shouldn't be a problem.
I'm also using rails3 with jQuery, but haven't seen any tutorials on how to do this in rails3.
My task/new.html.erb
<%= form_for @task, :html=>{:multipart => true do |f| %>
<%= render 'form', :f=>f %>
< end >
for my task/_form.html.erb
<%= f.label :task_name %>
<%= f.text_field :task_name %>
<%= f.label :media %>
<%= f.file_field :media %>
< div id="steps" >
<%= render 'steps/form', :f=> f % >
< /div>
<%= link_to_function "Add Step" do |page|
page.insert_html :bottom, :steps, :partial=>'steps/form', :object => Step.new end %>
<%= f.submit %>
steps/form.html.erb
<p class="fields">
<%= fields_for :steps do |builder| %>
<%= builder.label :title >
<%= builder.text_field :title >
<%= builder.label :description %>
<%= builder.text_area :description %>
<% end %>
</p>
The page loads fine, but when I click the 'add step link', I get two javascript errors.
RJS error: TypeError: Element.insert is not a function
then
Element.insert("steps", {bottom: "<p class=\"fields\">\n\t</p>\t"});