I am struggling with this Ajax call from Rails 2:
def add_task_link(name)
link_to_function name do |page|
page.insert_html :bottom, :tasks, :partial => 'task', :object => Task.new
end
end
How can I express this with Rails 3?
Thanks,
There are some hints in this project in Github: https://github.com/ryanb/complex-form-examples
def link_to_add_fields(name, f, association) new_object = f.object.class.reflect_on_association(association).klass.new fields = f.fields_for(association, new_object, :child_index => "new_#{association}") do |builder| render(association.to_s.singularize + "_fields", :f => builder) end link_to_function(name, "add_fields(this, \"#{association}\", \"#{escape_javascript(fields)}\")") endAdditionally, it is important to use accepts_nested_attributes_for as shown in
https://github.com/ryanb/complex-form-examples/blob/master/app/models/survey.rb