Before this commit, if we specify options for translates on a model, those options will be silently dropped if we integrate this example code.
To illustrate, if we have a model with a translated field, e.g.
class MyModel < ActiveRecord::Base
translates :label, fallbacks_for_empty_translations: true
end
Then with the original example code, the call to params.extract_options! will cause our added option (fallbacks_for_empty_translations) to be removed from params. When super is called, params will be passed automatically, but it will now be missing any options we have specified at the model level. The net effect is that fallbacks for empty translations will not be enabled as expected.
Working with a copy of the passed params works around this issue.
Before this commit, if we specify options for
translates
on a model, those options will be silently dropped if we integrate this example code.To illustrate, if we have a model with a translated field, e.g.
Then with the original example code, the call to
params.extract_options!
will cause our added option (fallbacks_for_empty_translations
) to be removed fromparams
. Whensuper
is called,params
will be passed automatically, but it will now be missing any options we have specified at the model level. The net effect is that fallbacks for empty translations will not be enabled as expected.Working with a copy of the passed
params
works around this issue.