I''m new to Ruby on Rails and I have what I thought was a simple
problem,
but I can''t get it to work.
I have a form which should save multiple rows into the mySQL table and I
am trying to use a block to loop through the code to write out to the
database but I can''t get the params to pass in the block.
I used this in my partial:
<%= text_field( :ticketing_price, :price_category, :index => @tdcount
) %>
<%= text_field( :ticketing_price, :number_available, :index =>
@tdcount ) %>
where as the @tdcount increases by one each time the partial is rendered
in the main view, therefore the name of the input is
name="ticketing_price[0][price_category]" ...
name="ticketing_price[1][price_category]''... etc
In my controller, I did this which apparently is wrong:
params[''ticketing_price''].each do |t|
ticketing_price = TicketingPrice.new
ticketing_price = ticketing_price[t]
ticketing_price.save
end
Please tell me what I am doing wrong. My models are setup correctly (at
least for saving one row at a time, without using the block).
thanks.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---