1

I have a form that populates various values, then posts those values to a page when the user submits. Now, I wish to see what params[] contains (by displaying it on the page I post to) just to fool around with my form definitions a little bit. I looked for an easy way to render params, but haven't quite found the solution. Any helpful suggestions SO?

thanks in advance

3 Answers 3

5

Another way is to make use of the helper functions for debugging as described in http://guides.rubyonrails.org/debugging_rails_applications.html

The technique, as previously described is to use params.to_yaml.

Alternatively, in your application.html.erb file put the code

<%= debug(params) if Rails.env.development? %>

after the <%= yield %> call

This will display in the view the params, for example

--- !map:ActiveSupport::HashWithIndifferentAccess 
action: edit
controller: contracts
id: "8"

The nice feature is that the information is only output in the Development mode environment, as per the check that is executed to determine which Rails environment is running.

3

Try <%= params.to_yaml %> in your view

0

Try using in this view in the view you are posting

    <%= params[:name_of_posted_param].each {|param|
    params //do something with the param here
} %>

A better way would be to do this in the helper and pass the returning variable in the view.

-R

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.