Rails ActiveRecord store and new session

后端 未结 3 465
轻奢々
轻奢々 2021-01-12 05:49

I am new to Rails and experience a strange issue I don\'t understand. I use ActiveRecord as a session store and need to add session id as a property of JSON responses for al

3条回答
  •  爱一瞬间的悲伤
    2021-01-12 06:11

    Without knowing the details of your application, my suggestion would be to use a before_filter in your ApplicationController:

    class ApplicationController < ActionController::Base
      before_filter :use_session_id
    
      protected
      def use_session_id
        # Do something with session.id 
        # This will get called before any rendering happens
      end
    end
    

提交回复
热议问题