Post variables

I need to display all the posted variables and their values. I am not
sure how I would go about doing this. Is there a way to loop through all
the posted variables regardless of how many are passed so I could
display them on a webpage? Thanks,

-S

I need to display all the posted variables and their values. I am not
sure how I would go about doing this. Is there a way to loop through
all
the posted variables regardless of how many are passed so I could
display them on a webpage? Thanks,

They're all in the params hash, which is just a regular ruby hash.

Fred

Frederick Cheung wrote:

They're all in the params hash, which is just a regular ruby hash.

Fred

I understand that part, but what if I don't neccissarily know the names
of the hash values? I know that there is always params[:action] and
params[:controller], but what if I had params[:id] when I hit one method
but when I hit another method I have a params[:admin_id], or something
completely different. I guess when I am trying to ask (and the easy way
would probably be just to try and see if it works) is, can I say
params.each and then loop through all the values that are passed in
regardless of what they are named before hand? Thanks,

-S

Since it’s a Hash, you can do each to go through the keys and values

eg

params.each { |k, v| puts “the key #{k} has value #{v}” }