-
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
new_framework_defaults_7_1.rb are not working as expected #46567
Comments
This usually happen because something in the application is loading |
Rechecked within a completely new app - works as expected. I originally checked within the existing app. I was able to identify 2 gems that load I am wondering if reassigning a local variable
ActiveRecord::Base is loaded earlier, is intentional? Because without that mutation everything works as expected with that 2 gems.
|
Unfortunately, this is a common issue caused by different gems. Another example: rollbar/rollbar-gem#906 I wish Rails would automatically identify issues like this, but I'm unsure how to implement it. |
There's a few ideas floating around. I think my favourite is #45297 @fatkodima are you able to share which gems had issues? Ideally they get patched.
Actually that reminds me of #46278 - another one caused by a third party issue. |
One is https://github.com/ledermann/unread, another one is mine - https://github.com/fatkodima/data_checks 😄
Ah, yes, haven't seen that. Had exactly the same idea. |
I think this is probably what you want the architecture to look like in your gem. But I agree that it would be better if Rails could handle this in more cases. |
Yes, thanks for looking into this. I will definitely fix my gem and probably send a PR into |
Opened a PR in |
@byroot @rafaelfranca do you think we will make any big changes for this in Rails 7.1? In any case I will close this particular issue as resolved. |
This is well known issue. We should prefer to code that reference active record only when it's already lazy loaded. It can break other gems initializing process Related: - rails/rails#46567 - paper-trail-gem/paper_trail@fc6c5f6 (inspiration) - thoughtbot/factory_bot_rails#432 Fix: DatabaseCleaner#89
This is well known issue. We should prefer to code that reference active record only when it's already lazy loaded. It can break other gems initializing process Related: - rails/rails#46567 - paper-trail-gem/paper_trail@fc6c5f6 (inspiration) - thoughtbot/factory_bot_rails#432 Fix: DatabaseCleaner#89
Here's another gem that loads ActiveRecord too early. It seems like they don't want to accept my PR unless I add a way to test it. Any ideas on a good way to test it? |
That's not really testable unless you have something like our Railties test that generate and boot an application. But it's very slow and doubt flipper will want just 20 seconds test. |
Steps to reproduce
config.load_defaults 7.0
inapplication.rb
Expected behavior
For example, in console
Actual behavior
Even though there is a test case for this -
rails/railties/test/application/configuration_test.rb
Lines 2497 to 2507 in cef42e6
The same situation applies for many of the configs in the
new_framework_defaults_7_1.rb.tt
file.Am I doing something wrong?
System configuration
Rails version:
main
The text was updated successfully, but these errors were encountered: