-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Set Active Record configurations on after_initialize #42499
Conversation
36422f7
to
374b73c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not be messing with after:
options in the initializers. It also move all other initializers out of order. Can you check if not other initialzier changed the order because of this after
option?
@@ -236,6 +228,18 @@ class Railtie < Rails::Railtie # :nodoc: | |||
end | |||
end | |||
|
|||
initializer "active_record.set_config", after: :load_config_initializers do |app| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also wrok for config/initializers
but Railties will still not be able to set config. I think this should happen as late is possible, maybe in an after_initialize
. That would avoid the need to use the after:
option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I tried that before and it wouldn't work, but it now does. Quite puzzling. Either way i think it's good to go now.
d7a857f caused a lot more failures and active record has a lot of deprecation warnings in the tests. Can we revert the changes to |
Done in 0305815 |
bc017bb
to
8561bb7
Compare
b459889
to
d2351fe
Compare
Otherwise you can't change `config.active_record.*` from `config/initializers`. Until now it somewhat worked because the config would be assigned when `ActiveRecord::Base` would be first referenced. But it was quite brittle anyway.
d2351fe
to
538998d
Compare
Otherwise you can't change
config.active_record.*
fromconfig/initializers
.Until now it somewhat worked because the config would be assigned when
ActiveRecord::Base
would be first referenced. But it was quite brittle anyway.I might merge this one quickly once I get a green CI as to fix the
main
branch. But I'd love to have second opinions on it.