rack-flash icon indicating copy to clipboard operation
rack-flash copied to clipboard

Doesn't work with JSON session cookies

Open gdelugre opened this issue 10 years ago • 0 comments

Flash keys are automatically converted to symbols. However symbols are not supported by JSON session cookies.

require 'sinatra/base'
require 'rack/flash'

class Server < Sinatra::Application
    configure do
        use Rack::Session::Cookie, coder: Rack::Session::Cookie::Base64::JSON.new
        use Rack::Flash 
    end

    get '/' do
        flash['foo'] = 'bar'
    end
end

Server.run!

Running this sample code produces the error:

Rack::Utils::OkJson::Error at /
Hash key is not a string: :foo

gdelugre avatar Jul 04 '15 22:07 gdelugre