Skip to content
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

Globalize load ActiveRecord too early (before initializers) #45

Closed
runephilosof-abtion opened this issue Nov 22, 2023 · 0 comments · Fixed by runephilosof-abtion/globalize-accessors#2 · May be fixed by #46
Closed

Globalize load ActiveRecord too early (before initializers) #45

runephilosof-abtion opened this issue Nov 22, 2023 · 0 comments · Fixed by runephilosof-abtion/globalize-accessors#2 · May be fixed by #46

Comments

@runephilosof-abtion
Copy link

Adding gem 'globalize-accessors' to 'Gemfile' in a new Rails app, will mean setting active_record configuration in initializers won't work.

Example

gem install rails
rails new example-globalize-rails-app --minimal
cd example-globalize-rails-app

echo "gem 'globalize', git: 'https://github.com/runephilosof-abtion/globalize.git', branch: 'fix-load-order'"
echo "gem 'globalize-accessors'" >> Gemfile
bundle

echo "Rails.application.config.active_record.collection_cache_versioning = false" >> config/initializers/new_framework_defaults_6_0.rb
echo "raise if ActiveRecord::Base.collection_cache_versioning == true" >> config/initializers/new_framework_defaults_6_0.rb

bin/rails runner 1

Maybe the code in https://github.com/globalize/globalize-accessors/blob/master/lib/globalize-accessors.rb#L64 needs to be wrapped in

ActiveSupport.on_load(:active_record) do
  # your code
end

https://guides.rubyonrails.org/engines.html#configuration-hooks

runephilosof-abtion added a commit to runephilosof-abtion/globalize-accessors that referenced this issue Nov 22, 2023
Fixes globalize#45
> Globalize load ActiveRecord too early (before initializers)

Which meant that setting active_record configuration in initializers did not work.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant