I have an model in my rails app called Dog. I want to create a form
where I can create an arbitrary amount of dogs with one request.
Here’s the default for creating a dog form:
New dog
<% form_for(@dog) do |f| %>
<%= f.error_messages %>
<%= f.label :confirmations %>
<%= f.text_field :confirmations %>
<%= f.label :name%>
<%= f.text_field :name%>
<%= f.submit 'Create' %>
<% end %>with this controller code:
def new
@dog= Dog.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @dog}
end
end
def create
@dog= Dog.new(params[:dog])
respond_to do |format|
if @ dog.save
flash[:notice] = 'dog was successfully created.'
format.html { redirect_to(@ dog) }
format.xml { render :xml => @ dog, :status
=> :created, :location => @ dog}
else
format.html { render :action => “new” }
format.xml { render :xml => @ dog.errors, :status
=> :unprocessable_entity }
end
end
end
So here I have a form where I can create a dog in the DB. How do I
create a form (and the respective controller code) to create 2 or 3
dogs?