Finding Array Key / Value Pairs

Hello,

I have an order form on my site where people can enter in the number of
products they want to buy. Once they have filled out the quantities and
press continue the form values look like this:

Parameters: {“commit”=>“Continue”, “order_form”=>{“127”=>“3”,
“128”=>“1”, “129”=>“0”, “130”=>“0”, “136”=>“0”, “137”=>“0”, “126”=>“2”}}

The first number in the “number pairs” is the ID of the product and the
second is the quantity they entered.

How can I loop over the “order_form” array a get both the first and
second value?

Any help appreciated!

On 10/4/06, Scott H. [email protected] wrote:

The first number in the “number pairs” is the ID of the product and the
second is the quantity they entered.

How can I loop over the “order_form” array a get both the first and
second value?

params[:order_form].each do |key,value|
end

Thanks, that is exactly what I was looking for. I just couldn’t find the
answer anywhere.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs