You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think an ideal location to put this line is a Rails initializer. However, since Zeitwerk comes enabled with Rails 6 by default, new apps have started throwing a deprecation warning:
DEPRECATION WARNING: Initialization autoloaded the constant MySessionClass.
Being able to do this is deprecated. Autoloading during initialization is going
to be an error condition in future versions of Rails.
Reloading does not reboot the application, and therefore code executed during
initialization does not run again. So, if you reload MySessionClass, for example,
the expected changes won't be reflected in that stale Class object.
These autoloaded constants have been unloaded.
It seems just writing this line in an initializer is going to raise an error in a future version of Rails. Please advise on the best method to resolve this.
The text was updated successfully, but these errors were encountered:
The code in the to_prepare block will run (at least) once for each request as part of re-loading the autoloaded constants (e.g., MySessionClass in this case). But based on both inspecting the code and my own experience using this technique, it's fine to set the session_class on each request.
I have a use case which requires a custom ActiveRecord session class implementation, and I provide that configuration as specified here:
I think an ideal location to put this line is a Rails initializer. However, since Zeitwerk comes enabled with Rails 6 by default, new apps have started throwing a deprecation warning:
It seems just writing this line in an initializer is going to raise an error in a future version of Rails. Please advise on the best method to resolve this.
The text was updated successfully, but these errors were encountered: