How can I add one more same set of inputs for example for education object, so I will have 2 new education objects after submitting? Preferable new set needs to be shown by clicking on icon that goes after existing set of inputs.
This is my new
method:
def new
@user = User.new
@user.educations.build
@user.works.build
end
And my view for it:
<%= simple_form_for [:admin, @user] do |u| %>
<%= u.error_notification %>
<%= u.input :name, label: "Name" %>
<p><b>Photo</b></p>
<%= image_tag(@user.photo_url, size: "80x90",
class:"img-rounded") if @user.photo? %>
<%= u.input :photo, label: false %>
<%= u.input :tel, label: "Tel.:" %>
<h3>Education</h3>
<hr>
<%= u.simple_fields_for :educations do |e| %>
<%= e.input :name, label: "University" %>
<%= e.input :year_started, label: "Started" %>
<%= e.input :year_finished, label: "Ended" %>
<% end %>
# icon `+`
<i class="fa fa-plus fa-2x"></i>
<h3>Work</h3>
<hr>
<%= u.simple_fields_for :works do |w| %>
<%= w.input :name, label: "Name" %>
<%= w.input :year_started, label: "Started" %>
<%= w.input :year_finished, label: "Ended" %>
<% end %>
<%= u.button :submit, "Надіслати" %>
<% end %>