我正在尝试更新已通过globalize3. 为此,我需要多次更改语言环境以更新模型。但是,该update_attributes方法似乎不接受块作为参数。有没有其他方法可以实现以下目标?
Country.where(code: 'NLD').first_or_create.update_attributes do |country|
I18n.locale = :en
nld.name = 'Netherlands, The'
I18n.locale = :nl
nld.name = 'Nederland'
end
我这样做的原因是我希望能够多次运行我的种子文件并相应地更新数据first_or_create。update_attributes