# Ruby/rails/debugger variable dump question

**URL:** <https://www.ruby-forum.com/t/ruby-rails-debugger-variable-dump-question/180724>\
**Category:** Rails\
**Created:** [December 27, 2009, 10:59pm UTC](https://www.ruby-forum.com/t/ruby-rails-debugger-variable-dump-question/180724 "2009-12-27T22:59:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ralphshnelvar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@ralphshnelvar](https://www.ruby-forum.com/u/ralphshnelvar)\
**Post date:** [December 27, 2009, 10:59pm UTC](https://www.ruby-forum.com/t/ruby-rails-debugger-variable-dump-question/180724/1 "2009-12-27T22:59:58Z")

</div>

newbie here.

(OT: Happy New Year, all.)

I placed a debugger statement into my ROR app and run  
ruby script/server webrick --debugger

My app hit the debugger statement.

I then did a  
var local

* * *

(rdb:68) var local  
\_ =\>  
exception =\> No route matches “/xxx” with {:method=\>:get}  
handler =\> #\<Method: #\<ApplicationController:0x6018a3c  
@action\_name=“index”, @\_response=#\<ActionController::Response:0x6018b40  
@session={“flash”=\>{}}, @redirected\_to=nil,

[snipped a ton of stuff]

## “HTTP\_ACCEPT”=\>“text/html,application/xhtml+xml, application/xml;q=0.9,_/_;q=0.8”, “REQUEST\_METHOD”=\>“GET”, “HTTP\_CONNECTION”=\>“keep-alive”}, @request\_method=:get, @parameters={}\>, @parameters={}\>\>.\_\_bind\_1261677328\_946000\> (rdb:68)

I have no idea how to interpret this or how to format this for pretty  
output.

So … by guess and by gosh (and because I read it somewhere) I then ran  
irb inside the debugger and did

* * *

(rdb:68) @\_response  
#\<ActionController::Response:0x6018b40 @session={“flash”=\>{}},  
@redirected\_to=nil,  
@writer=#Proc:0x0612469c@f:/Ralph-Rails-Apps/authlogic/vendor/rails/actionpack/lib/action\_controller/response.rb:46,  
@request=#\<ActionController::Request:0x6018b68

[snipped a ton of stuff]

## @assigns={}, @helpers=#ActionView::Base::ProxyModule:0x6018960\>, @body=["", nil, [], []], @assigns=[], @header={“Cache-Control”=\>“no-cache”}, @status=200\>

Since that was no better for me to understand, I tried (because I saw it  
somewhere)  
y @\_response  
inside irb

I don’t even see y documented as a debugger command.

* * *

irb(#ApplicationController:0x6018a3c):002:0\> y @\_response  
— &id007 !ruby/object:ActionController::Response  
assigns: &id001 []

block:  
body:

- “”
- 
- \*id001
- []

header: &id005 !map:Rack::Utils::HeaderHash  
Cache-Control: no-cache  
redirected\_to:  
request: &id003 !ruby/object:ActionController::Request  
content\_type:  
env:  
rack.session.record:  
!ruby/object:ActiveRecord::SessionStore::Session  
attributes:  
updated\_at: 2009-12-24 06:54:00  
session\_id: fab30d62f08ae89e5b87d68bb1647c3c  
id: “1”  
created\_at: 2009-12-24 06:54:00  
data: |  
BAh7BiIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxhc2g6OkZsYXNo  
SGFzaHsABjoKQHVzZWR7AA==

```
  attributes_cache: {}

  data:
    flash: &id002 !map:ActionController::Flash::FlashHash {}

action_controller.rescue.request: *id003
SERVER_NAME: localhost
rack.request.cookie_hash:
  _session_id: fab30d62f08ae89e5b87d68bb1647c3c

```

[snipped a ton of stuff]

```
  request: *id003

```

helpers: !ruby/object:ActionView::Base::ProxyModule  
receiver: \*id008  
view\_paths: !seq:ActionView::PathSet  
- !ruby/object:ActionView::ReloadableTemplate::ReloadablePath  
disk\_cache: {}

```
  path: f:/Ralph-Rails-Apps/authlogic/app/views
  paths: {}

```

writer: !ruby/object:Proc {}

=\> nil  
irb(#ApplicationController:0x6018a3c):003:0\>

* * *

That’s a bit better but still mostly uninterpretable to me.

So … how would I get programmatic access to, say, SERVER\_NAME or the  
\_session\_id?

Is there documentation on how to use the debugger other than “help” or  
page 216 in the Pickaxe book?

---

<div class="post-metadata">

**Author:** ![ralphshnelvar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@ralphshnelvar](https://www.ruby-forum.com/u/ralphshnelvar)\
**Post date:** [December 28, 2009, 1:27am UTC](https://www.ruby-forum.com/t/ruby-rails-debugger-variable-dump-question/180724/2 "2009-12-28T01:27:22Z")

</div>

On Dec 27, 10:59 pm, Ralph S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> newbie here.
> 
> (OT: Happy New Year, all.)
> 
> I placed a debugger statement into my ROR app and run  
> ruby script/server webrick --debugger
> 
> My app hit the debugger statement.

[snip]

> Since that was no better for me to understand, I tried (because I saw it  
> somewhere)  
> y @\_response  
> inside irb
> 
> I don’t even see y documented as a debugger command.

It’s not - it’s a method that is part of the ruby standard library: it  
dumps the argument passed to it as yaml. It’s mostly normal that this  
doesn’t make any sense to you - it’s exposing a lot of internal state  
from the response object. A good place to start would be to look at  
the api for the Response object and try the things you see there.

> 

[snip]

> That’s a bit better but still mostly uninterpretable to me.
> 
> So … how would I get programmatic access to, say, SERVER\_NAME or the  
> \_session\_id?

The debugger will run ruby code for you, so do exactly what you would  
do if you were writing code in that part of your app (eg if you’re in  
a controller you could look at request.host or request.env

> Is there documentation on how to use the debugger other than “help” or  
> page 216 in the Pickaxe book?

just FYI, ruby-debug is not the same as the debugger described in the  
pickaxe

Fred

> –  
> Posted viahttp://www.ruby-forum.com/.

–

You received this message because you are subscribed to the Google  
Groups “Ruby on Rails: Talk” group.  
To post to this group, send email to removed\_email\_address@domain.invalid.  
To unsubscribe from this group, send email to  
removed\_email\_address@domain.invalid.  
For more options, visit this group at  
[http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).
