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
If I set Rails.application.config.active_record.belongs_to_required_by_default = false in an initializer, I should be able to run rails c and get the following output:
Would seem to be as simple as adding geocoder to a rails app and adding the setting above in an initializer.
Cause
So this was a weird one to track down, because we had no idea what was causing the setting to get nuked. Per an issue raised in the rails project, it seems that ActiveRecord::Base looks up and sets its configuration when it is first loaded. However, in commit 5d92d0b to this project, ActiveRecord::Base is caused to load earlier than it is supposed to be (namely, before: :load_config_initializers) so the app's configuration gets silently ignored.
Environment info
Geocoder version: 1.6.5
Rails version: 6.1
The text was updated successfully, but these errors were encountered:
Thanks for reporting this. Just to clarify, and to make sure I understand the issue: in your example, wouldn't you expect ActiveRecord::Base.belongs_to_required_by_default to return false?
@alexreisner , oh, I'm sorry, I screwed this up. Actual behavior was it returns true. This is because it's the rails default and my change to it didn't take effect. I do expect it to return false, but it doesn't.
No worries. I just wanted to make sure we're on the same page (thanks for updating the issue). It may take me a couple of days to find time to investigate this, but I wanted to let you know I'm on it, and my initial instinct is that you're right. The solution ideally won't break whatever that commit was trying to fix (which I don't recall at the moment).
Expected behavior
If I set
Rails.application.config.active_record.belongs_to_required_by_default = false
in an initializer, I should be able to runrails c
and get the following output:Actual behavior
true
is returnedSteps to reproduce
Would seem to be as simple as adding
geocoder
to a rails app and adding the setting above in an initializer.Cause
So this was a weird one to track down, because we had no idea what was causing the setting to get nuked. Per an issue raised in the
rails
project, it seems thatActiveRecord::Base
looks up and sets its configuration when it is first loaded. However, in commit 5d92d0b to this project,ActiveRecord::Base
is caused to load earlier than it is supposed to be (namely,before: :load_config_initializers
) so the app's configuration gets silently ignored.Environment info
The text was updated successfully, but these errors were encountered: