[Rails]how can i save multiple record in new from when i use scaffold

50 Views Asked by At

if i make one scaffold code like this

rails g scaffold Order name:string item:string
rake db:migrate

then in 'app/views/orders/_form.html.erb' there is form for one record of Order model

and in orders_controller.rb

def new
  @order = Order.new
end

but i want to get multiple record for Order in one form

how can i do this? I tried

def new
  @orders = []
  4.times do
     @orders << Order.new
  end
end

but after this code i cannot do anything...can anyone help me please

0

There are 0 best solutions below