Guest User

Untitled

a guest
May 25th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. def link_to_add_fields(name, f, association)
  2. new_object = f.object.class.reflect_on_association(association).klass.new
  3. fields = f.fields_for(association, [new_object], :child_index => "new_#{association}") do |builder|
  4. render(association.to_s.singularize + "_fields", :f => builder)
  5. end
  6. link_to_function(name, h("add_fields(this, \"#{association}\", \"#{escape_javascript(fields)}\")"))
  7. end
Add Comment
Please, Sign In to add comment