In rails from byebug, how can I view the output of the session variable as a string, displaying only part of it?
I can view the output of the session variable from the console but it is really long. If I could put that in a string and do e.g. thestr[1,100] . then that'd be ok. But I can't see how to get it into a string.
~/rubymac/cookiesandsessions/sessiontest1$ rails s
=> Booting Puma
=> Rails 5.2.3 application starting in development
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.12.1 (ruby 2.5.0-p0), codename: Llamas in Pajamas
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://localhost:3000
Use Ctrl-C to stop
Started GET "/" for 127.0.0.1 at 2019-04-24 15:34:03 +0100
Processing by ApplicationController#index as HTML
Return value is: nil
[1, 5] in /Users/apple/rubymac/cookiesandsessions/sessiontest1/app/controllers/application_controller.rb
1: class ApplicationController < ActionController::Base
2: def index
3: byebug
=> 4: end
5: end
As you can see, the response from session is really long. And I can't see how to display e.g. only the first 100 characters. e.g. thestr[0,100]
(byebug) session
@app=#>, @cache_control="max-age=0, private, must-revalidate", @no_cache_control="no-cache">>>>, @default_options={:path=>"/", :domain=>nil, :expire_after=>nil, :secure=>false, :httponly=>true, :defer=>false, :renew=>false}, @key="_sessiontest1_session", @cookie_only=true>, @req=#[1, 3], "rack.errors"=>#>, "rack.multithread"=>true, "rack.multiprocess"=>false, "rack.run_once"=>false, "SCRIPT_NAME"=>"", "QUERY_STRING"=>"", "SERVER_PROTOCOL"=>"HTTP/1.1", "SERVER_SOFTWARE"=>"puma 3.12.1 Llamas in Pajamas", "GATEWAY_INTERFACE"=>"CGI/1.2", "REQUEST_METHOD"=>"GET", "REQUEST_PATH"=>"/", "REQUEST_URI"=>"/", "HTTP_VERSION"=>"HTTP/1.1", "HTTP_HO ............ ...........
I tried session.to_s but that makes this string so it doesn't just convert the above output to string.
(byebug) session.to_s
"#<ActionDispatch::Request::Session:0x00007fa60ee91270>"
(byebug)