2

我有一個rails引擎代碼。但Rails :: Engine沒有config.session_store變量。Rails 3.2引擎如何將會話保存在數據庫中?

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 

我如何使用數據庫會話存儲?

回答

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 
相關問題