I’ve been trying to configure a submit form where users can add multiple records to a database at once by adding extra fields with jQuery. (users with names and emails)
But it submits only a single row of data and ignores the rest.
Any advice would be greatly appreciated. Thanks.
<%= semantic_form_for target.users.new, :url => resource_url, :remote => true do |f| %>
<%= f.inputs do %>
<%= f.input :email%>
<%= f.input :name%>
<%= f.input :email, :object =>target.users.new%>#??????? - Here is problem.
<%end%>
<%= f.buttons %>
<%end%>
target – this is parent object
If email is a field, then your users will type several email addresses into a single input field, and you don’t need the
:object => target.users.newbit at all. You could serialize this as an array before saving to the db – but my guess is what you are trying to do is add an email object – ie you have a User model which has_many :emails – in which case you need to useaccepts_nested_attributes :emailin the User model and:fields_for :emailin the view