Question

I have a rails engine code. But Rails::Engine don't have config.session_store variable.

module Admin
  class Engine < ::Rails::Engine
    isolate_namespace Admin

    config.autoload_paths << File.expand_path("../..", __FILE__)
    config.session_store :active_record_store

    config.generators do |g|
      g.javascript_engine :coffee
      g.stylesheet_engine :less
      g.template_engine :haml
      g.test_framework :rspec, :view_specs => false
    end
  end
end

How i can use databas session storage?

Was it helpful?

Solution

Solution:

module Admin
 class Engine < ::Rails::Engine
   isolate_namespace Admin

    config.autoload_paths << File.expand_path("../..", __FILE__)
    config.generators do |g|
      g.javascript_engine :coffee
      g.stylesheet_engine :less
      g.template_engine :haml
      g.test_framework :rspec, :view_specs => false
    end

    initializer "Admin.add_middleware" do |app|
      ActiveRecord::SessionStore::Session.table_name = 'admin_sessions'
      app.middleware.use ActiveRecord::SessionStore
    end
  end
end
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top