Files
nairobi/config/initializers/globalize.rb
Javi Martín e8195c201d Avoid warnings during initialization
These warnings appear in the logs in the development environment, and,
with Rails 7, the application will crash. When running the tests, they
would appear in the standard error ouput if we set `config.cache_classes
= false` in the test environment but, since that isn't the case, they
don't.

To reproduce these warnings (or the lack of them), start a Rails console
in development and check the log/development.log file.
2024-04-11 19:08:02 +02:00

26 lines
659 B
Ruby

Rails.application.reloader.to_prepare do
Globalize::ActiveRecord::Translation.class_eval do
include SkipValidation
end
end
module Globalize
module ActiveRecord
module InstanceMethods
def save(...)
# Credit for this code belongs to Jack Tomaszewski:
# https://github.com/globalize/globalize/pull/578
Globalize.with_locale(Globalize.locale || I18n.default_locale) do
super
end
end
end
end
end
def Globalize.set_fallbacks_to_all_available_locales
Globalize.fallbacks = I18n.available_locales.index_with do |locale|
(I18n.fallbacks[locale] + I18n.available_locales).uniq
end
end