Globalize creates a translation for the current locale, and the only way I've found to change this behaviour is to monkey-patch it. The original code uses `translation.locale` instead of `Globalize.locale`. Since `translation.locale` loads the translation with empty attributes. It both makes the record invalid if there are validations and it makes it almost impossible to create a record with translations which don't include the current locale. See also the following convertations: https://github.com/globalize/globalize/pull/328 https://github.com/globalize/globalize/issues/468 https://github.com/globalize/globalize/pull/578 https://github.com/shioyama/mobility/wiki/Migrating-from-Globalize#blank-translations
14 lines
332 B
Ruby
14 lines
332 B
Ruby
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
|