Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails: How do I print the request parameters?

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.

like image 237
Nerian Avatar asked Jan 29 '11 16:01

Nerian


People also ask

What is params ID in Rails?

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.

How does params work in Rails?

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.


1 Answers

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 %> 
like image 76
Rob Di Marco Avatar answered Sep 18 '22 23:09

Rob Di Marco