views:

57

answers:

2

I want to loop through all the variables stored in the session. I checked and it appears that sessions are stored as a hash: request.session.kind_of?(Hash) - returns true

I wasn't sure why the following code didn't work: request.session.each {|key, value| puts keys + " --> " + value

I am trying to output all session variables as part of a debug view.

+1  A: 

Instead of:

request.session.each {|key, value| puts keys + " --> " + value

Use:

request.session.each {|key, value| puts key.to_s + " --> " + value.to_s }
Tomas Markauskas
A: 

<%= debug session %> might be easier.

Use it like this:

<% if ENV['RAILS_ENV'] == 'development' %>
    <%= javascript_include_tag 'prototype' %>
           <%= debug session %>
           <%= debug params %>                   

<% end %>
srboisvert