I'm new to rails. I have some question that's been quite a headache to me, so here it is:
For example i have this controller & view:
Controller:
class OrdersController < ApplicationController
def new
@Order = Order.new
end
def create
@Order = Order.new(params[:order])
if @Order.save
flash[:notice] = "Successfully created order."
redirect_to @Order
else
render :action => 'new'
end
end
View:
<% title "Menu Order" %>
<%= form_for @Order do |f| %>
<%= f.error_messages %>
<div id="form-order">
<p>
<%= f.label :name%><br />
<%= f.text_field :name, %>
</p>
<p>
<%= f.label :menu_order %><br />
<%= f.text_field :menu_order %>
</p>
</div>
<%= f.submit %>
So my question is :
before displaying the form above, I want to have a text_field_tag that specify how many forms (roughly said, duplicate the form div) I want to generate based on count, and then insert the data to the database simultaneously, the ide开发者_运维技巧a is to speed things up, so that the user don't have to input the data only one at a time, but multiple record at single submit
How do I do that?
精彩评论