0
我在写一个需要使用session_id销毁任意会话的gem。Rails:使用session_id销毁会话
目前我使用如下代码
case Rails.application.config.session_store
when ActionDispatch::Session::CacheStore
Rails.cache.delete("_session_id:#{session_id}")
when ActionDispatch::Session::ActiveRecordStore
ActiveRecord::SessionStore.session_class.find(session_id).destroy
when ActionDispatch::Session::CookieStore
# cannot remove a client-storage session
end
但我发现每一个SessionStorage
类destroy_session(env, session_id, options)
方法。我怎样才能在脚本中调用这个方法? (不是在请求或任何控制器)
对不起,我没有说清楚。我目前正在编写一个需要通过session_id销毁任意会话的gem。所以我想调用一些方法,比如'ActionDispatch :: Session :: CacheStore#destroy_session'。但我不知道该怎么称呼它。 –