Ruby on Rails Sunday, July 3, 2011

hello everyone, I'm new to rails 
i have some question thats 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 %>

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,

This is similar to ryan bates railscasts but they don't meet my requirement, i want to use single model, not nested.

the idea 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?

Any suggestions and solutions  will be much appreciated 

thanks before :)

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/aA4013ayyooJ.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment