Skip to content

Instantly share code, notes, and snippets.

@RSpace
Created May 17, 2010 12:01
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save RSpace/403687 to your computer and use it in GitHub Desktop.
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, h("add_fields(this, \"#{association}\", \"#{escape_javascript(fields)}\")"))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment