Technology and Software

Factory_girl and Globalize3

This is a quick one. I had to populate a test database with models with attributes translated with Globalize3. There are validations that fail if those attributes are not set before saving the record. This is the correct code:

record = Factory.build(:model)
I18n.available_locales.each do |locale|
  Globalize.with_locale(locale) do
    record.attribute = "Model_attribute_#{locale} #{n}"
  end
end
model.save


 

Standard