singleton can't be dumped error on flash
Closed this issue · 3 comments
Getting a singleton can't be dumped
error when setting a flash followed by a redirect:
post '/login' do
flash[:success] = 'nope'
redirect '/login', 303
end
Stacktrace
/Users/eriklott/.rvm/gems/ruby-2.0.0-p247/gems/rack-1.5.2/lib/rack/session/cookie.rb: in dump
super(::Marshal.dump(str))...
/Users/eriklott/.rvm/gems/ruby-2.0.0-p247/gems/rack-1.5.2/lib/rack/session/cookie.rb: in encode
super(::Marshal.dump(str))...
/Users/eriklott/.rvm/gems/ruby-2.0.0-p247/gems/rack-1.5.2/lib/rack/session/cookie.rb: in set_session
session_data = coder.encode(session)...
/Users/eriklott/.rvm/gems/ruby-2.0.0-p247/gems/rack-1.5.2/lib/rack/session/abstract/id.rb: in commit_session
if not data = set_session(env, session_id, session_data, options)...
/Users/eriklott/.rvm/gems/ruby-2.0.0-p247/gems/rack-1.5.2/lib/rack/session/abstract/id.rb: in context
commit_session(env, status, headers, body)...
/Users/eriklott/.rvm/gems/ruby-2.0.0-p247/gems/rack-1.5.2/lib/rack/session/abstract/id.rb: in call
context(env)...
/Users/eriklott/.rvm/gems/ruby-2.0.0-p247/gems/rack-1.5.2/lib/rack/showexceptions.rb: in call
@app.call(env)...
/Users/eriklott/.rvm/gems/ruby-2.0.0-p247/gems/rack-1.5.2/lib/rack/logger.rb: in call
@app.call(env)...
/Users/eriklott/.rvm/gems/ruby-2.0.0-p247/gems/scorched-0.19/lib/scorched/static.rb: in call
response[0] >= 400 ? @app.call(env) : response ...
/Users/eriklott/.rvm/gems/ruby-2.0.0-p247/gems/rack-accept-0.4.5/lib/rack/accept/context.rb: in call
@app.call(env)...
/Users/eriklott/.rvm/gems/ruby-2.0.0-p247/gems/rack-1.5.2/lib/rack/methodoverride.rb: in call
@app.call(env)...
/Users/eriklott/.rvm/gems/ruby-2.0.0-p247/gems/rack-1.5.2/lib/rack/head.rb: in call
status, headers, body = @app.call(env)...
I can see why it's happening. The after
filter for the flash session data isn't kicking off because redirecting halts the request, which exits the current controller as quickly as possible, skipping the after
filters. Halting however should still run the after
filters, unless halt
is called within a filter. I'm not sure when this changed or why, but it may have been an unintended side effect of minor refactor.
I'll see if I can find the commit responsible for the change, and see if there's any clue as to why this was changed, if it indeed was done intentionally. Either way, I'll get the issue fixed.
This will be pushed up soon; finding the best solution requires careful consideration as every change has a knock-on effect. I've made a few additional changes also which I'll release as v0.20.
Ok, I took a little longer than I would have liked, but being the party time of year and with work being unusually hectic, you'll have to forgive me.
v0.20 has just been released. I ended up making quite a few changes, including giving a few things a bit of polish.