我有一个rails引擎代码。但是Rails :: Engine没有config.session_store变量。
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
我如何使用数据库会话存储?
答案 0 :(得分:3)
解决方案:
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