0

I have a Rails app that uses sessions and which I was using in Chrome on localhost. After I shut it down, I started up another app in Chrome that doesn't use sessions and got a sessions error referring to a class that doesn't exist in the new sessionless app.

ActionDispatch::Session::SessionRestoreError (Session contains objects whose class definition isn't available.
Remember to require the classes for all objects kept in the session.
(Original exception: uninitialized constant Question [NameError])
):

When I try the new 'sessionless' app in another browser (that I didn't use before), it works fine even while it continues not to work in Chrome, so i'm guessing that the sessions from the first app are hanging around in chrome and interferring with the second. I cleared the cache but it's still not working (so I probably have to clear it again 1000 more times in Chrome), however, I also found this method

reset_session

http://api.rubyonrails.org/classes/ActionController/Base.html#M000668

but when I put it in Application controller (hoping it would clear all sessions throughout the app), it says undefined local variable or method.

Two questions

1) is the behavior expected, namely that the sessions from the first app affect the functioning of the second app?

2) how should I be using reset_session to avoid this problem, or is there another way to?

update the app worked in Chrome after clearing the cache, but I'd still like to know how to use reset_session if possible

4

1 に答える 1

0

Rails のベスト プラクティスは、Ruby バージョン マネージャーを使用することです。RVM で ruby​​ を再インストールすると、このような問題をデバッグするよりも時間がかかりません。

https://rvm.io/

于 2013-02-05T03:04:13.847 に答える