# Newbie block question

**URL:** <https://www.ruby-forum.com/t/newbie-block-question/117984>\
**Category:** Rails\
**Created:** [October 22, 2007, 11:44pm UTC](https://www.ruby-forum.com/t/newbie-block-question/117984 "2007-10-22T23:44:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![zhasper](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/85f322/32.png) [@zhasper](https://www.ruby-forum.com/u/zhasper)\
**Post date:** [October 22, 2007, 11:44pm UTC](https://www.ruby-forum.com/t/newbie-block-question/117984/1 "2007-10-22T23:44:44Z")

</div>

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.
