2

私はレールエンジンコードを持っています。しかし、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 

どのように私はdatabasセッションストレージを使用できますか?

答えて

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 
関連する問題