I have a Rails 5 app in which I use Globalize for localization. I'm currently having an issue where I can't save new objects if they don't have any translations.
My model looks like this:
# Product.rb
translates :description, :fallbacks_for_empty_translations => true
has_many :translations
accepts_nested_attributes_for :translations
# ProductTranslation.rb
belongs_to :product, optional: true
My database schema looks for my product_translations looks like this:
t.integer "product_id", null: false
t.string "locale", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.text "description"
t.index ["locale"], name: "index_product_translations_on_locale"
t.index ["product_id"], name: "index_product_translations_on_product_id"
When I try to save new products I currently get this error:
Unable to save product with id = got these validation errors {:"translations.globalized_model"=>["translation missing: sv.activerecord.errors.models.product/translation.attributes.globalized_model.required"]}
Any ideas on what I can do to make it work?
has_many :product_translations
- from your code examples giventranslations
isn't a model. – Tenderhearted