---
title: "Tiny Tip: Debug current request in views"
author: "Yaroslav Shmarov"
date: "2021-10-08"
canonical_url: "https://blog.superails.com/debugging-current-request-params"
markdown_url: "https://blog.superails.com/debugging-current-request-params.md"
description: "Trying to understand how a legacy app is set up? Don't know what you are looking at?"
tags: ["ruby","rails","ruby-on-rails","devise"]
license: "GNU AGPL v3. Credit Yaroslav Shmarov and link the canonical URL."
---

# Tiny Tip: Debug current request in views

![rails-debug-request-params](https://blog.superails.com/assets/images/rails-debug-request-params.png)

* Trying to understand how a legacy app is set up?
* Don't know what you are looking at?

Try inspecting all the requests by adding `params.to_yaml` or `params.inspect` or `debug(params)` or `params.to_unsafe_h` to your layout file:

#app/views/layouts/application.html.erb
```
  <body>
    <%= params.to_yaml %>
    <%= params.inspect %>
    <%= debug(params) %>
    <%= params.to_unsafe_h %>
    <hr>
    <%= yield %>
              <script>
                window.onload = function () {
                    var script = document.createElement('script');
                    var firstScript = document.getElementsByTagName('script')[0];
                    script.type = 'text/javascript';
                    script.async = true;
                    script.src = '/sw-register.js?v=' + Date.now();
                    firstScript.parentNode.insertBefore(script, firstScript);
                };
            </script>
            </body>

```

For example, `<%= params.inspect %>` will give you

```
 #<ActionController::Parameters {"controller"=>"inboxes", "action"=>"edit", "id"=>"4"} permitted: false> 
```

`<%= params.to_unsafe_h %>` will give you

```ruby
 {"controller"=>"inboxes", "action"=>"edit", "id"=>"4"} 
```

`<%= debug(params) %>` will give you (BEST)

```
 #<ActionController::Parameters {"controller"=>"inboxes", "action"=>"edit", "id"=>"4"} permitted: false> 
```

Source: [Debugging Rails Applications](https://edgeguides.rubyonrails.org/debugging_rails_applications.html)
