SHARE
TWEET

Untitled

a guest Apr 21st, 2017 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <tbody>
  2.      <%= f.simple_fields_for :saleslines do |salesline| %>
  3.           <%= render 'salesline_fields',f: salesline %>
  4.         <%end%>
  5.     <td><%= link_to_add_fields "add button", f, :saleslines %></td>
  6.    
  7. module ApplicationHelper
  8.   def link_to_add_fields(name, f, association)
  9.   new_object = f.object.send(association).klass.new
  10.   id = new_object.object_id
  11.   fields = f.fields_for(association, new_object, child_index: id) do |salesline|
  12.   render(association.to_s.singularize + "_fields", f: salesline)
  13. end
  14. link_to(name, '#', class: "add_fields", data: {id: id, fields: fields.gsub("n", "</td>")})
  15.  end
  16. end
  17.    
  18. <tr><td>asdasd</td>
  19. <td class="state-1">111</td>
  20. <td class="state-2">222</td>
  21. <td>333</td>
  22. <td>asdasd</td></br>
  23. <td>asdasd</td></br>
  24. </tr>
RAW Paste Data
Top