2

레일 엔진 코드가 있습니다. 그러나 Rails :: Engine에는 config.session_store 변수가 없습니다.Rails 3.2 Engine 어떻게 데이터베이스에 세션을 저장할 수 있습니까?

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 
관련 문제