Robert Mela asked:

How to switch session stores?

Tags: 0.50

By default cookie session store is used in Nitro pre-0.50

The line in application.rb that does this is

@session_store ||= Raw::CookieSessionStore.new

In my app setup I tried this:

require 'raw/context/session/memory'

app.session_store = Raw::MemorySessionStore.new

The problem with that is the 'require' looks like it digs a little deeper into the Raw framework than it should. Shouldn't there be a simpler way to do this?

thx.

(1 attempts)

Kashia answered:

This is more of a developer-interface question or rather 'request'.

How about the following:

class Application
  def session_store=(store)
    @session_store =
      if store.is_a?(Symbol)
        store = store.to_s.downcase
        require "raw/context/session/#{store}"
        Raw.const_get("#{store.modulize}SessionStore").new
      else
        store.new
      end
  end
end

And for the user interface:

app.session_store = :memory

If you like that idea, get George to implement it. ;)

Rating: 5