-
Notifications
You must be signed in to change notification settings - Fork 228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sorcery breaks Rails defaults from initializers for ActiveRecord #312
Comments
The way Sorcery currently loads has caused a plethora of issues, I wouldn't be surprised if this is one of them. Sorcery v1 will use a railtie and properly hook into the bootstrapping system. That said, I have unfortunately been incredibly behind schedule on pushing v1 to a production ready state. The conditional loading depending on if Rails is present has been tried, and unfortunately breaks things horribly. The easiest solution to this would probably be to finish Sorcery v1. I'm not sure if there's any workarounds can be be used in the meantime, but if there are please post them here for others that may be running into the same issue! |
Thanks for letting me know about this. The only workaround we have come up with is to move the default overrides from the initializer that There is also a PR open on the rails repo discussing how to fix this for the whole ecosystem. |
We are working on upgrading a Rails 5 app and the Rails 5.2 update adds
new_framework_defaults_5_2.rb
with:# Rails.application.config.active_record.cache_versioning = true
When that is commented, cache keys look like this:
When it is uncommented, it changes the output to this:
When I add sorcery to the project, though, the cache key reverts to the former version.
If I comment sorcery out in the Gemfile, then the cache key is the correct value again.
I have created a reproduction app, with exact reproduction instructions in the readme, here.
I believe this is happening because sorcery loads ActiveRecord too early. I debugged similar issues with recaptcha and wicked_pdf for ApplicationController.
You can see how recaptcha fixed it by converting to using a railtie here.
You can see how wicked_pdf fixed it the same way here.
I realize sorcery supports frameworks other than Rails, but I'm hoping that a Rails check can be used to fix this. If the application is a Rails application, then load using
ActiveSupport.on_load
. Otherwise, load as it currently does. I saw thatengine.rb
references needing to do this forActionController
too, but there are issues for pre-existing code.I'd be happy to create a PR, but I'm not sure about the issues that pre-existing code was experiencing.
Configuration
master
2.6.10
Rails 5.2
, presumably up tomain
branchMacOS
Expected Behavior
Rails initializers for ActiveRecord should work.
Actual Behavior
They do not necessarily work
Steps to Reproduce
Please see https://github.com/brandoncc/sorcery-error-reproduction-rails-app.
The text was updated successfully, but these errors were encountered: