Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

suport for ActionDispatch::Request::Session as session object #113

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

equivalent
Copy link
Contributor

in Rails 4 env['rack.session'] is ActionDispatch::Request::Session object => doesn't respond to #each 2

   13: def session
    14:   parameter_filter = ActionDispatch::Http::ParameterFilter.new(env['action_dispatch.parameter_filter'])
    15: 
 => 16:   binding.pry
    17: 
    18:   env_session = begin
    19:     env['rack.session'].to_hash
    20:   rescue NoMethodError
    21:     env['rack.session'] || { }
    22:   end
    23: 
    24:   parameter_filter.filter(env_session)
    25: end

[4] pry(#<PartyFoul::IssueRenderers::Rails>)> env['rack.session'].respond_to?(:each)
=> false
[5] pry(#<PartyFoul::IssueRenderers::Rails>)> env['rack.session'].class
=> ActionDispatch::Request::Session

# so :

[6] pry(#<PartyFoul::IssueRenderers::Rails>)> parameter_filter.filter(env['rack.session'])
NoMethodError: undefined method `each' for #<ActionDispatch::Request::Session:0x000000023718e0>
from /home/tomi/.rvm/gems/ruby-2.1.2@validations/gems/actionpack-4.0.9/lib/action_dispatch/http/parameter_filter.rb:51:in `

# but

[7] pry(#<PartyFoul::IssueRenderers::Rails>)> parameter_filter.filter(env['rack.session'].to_hash)
=> {"session_id"=>"df7cf659a9c513ed84a496b747132319 ..... 

@equivalent
Copy link
Contributor Author

anyone have any opinion on this ?

@snatchev
Copy link

snatchev commented Apr 2, 2015

👍 We've been experiencing a lot of "silent errors" due to this issue.

@defeated
Copy link
Contributor

We just ran into this.

For posterity, here is how bugsnag solved the same problem (slightly different approach, doesn't use exception handling as flow control):

https://github.com/bugsnag/bugsnag-ruby/pull/152/files

@equivalent
Copy link
Contributor Author

do guys want me to rewrite this to if statements ? or is the exception capturing ok ?

@jmorais
Copy link

jmorais commented Sep 20, 2015

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants