I have a Rails 3 application and I want to print in the view the request parameters. How do I do it?
Edit:
The purpose is to see what is being sent in a Form.
params[:id] is meant to be the string that uniquely identifies a (RESTful) resource within your Rails application. It is found in the URL after the resource's name.
As others have pointed out, params values can come from the query string of a GET request, or the form data of a POST request, but there's also a third place they can come from: The path of the URL. As you might know, Rails uses something called routes to direct requests to their corresponding controller actions.
If you wanted to print all of the parameters, the easiest way would be to use the inspect
puts params.inspect
or better, use the Rails logger
Rails.logger.debug params.inspect
In your html/ERB, you can use
<%= params.inspect %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With