How do I set up fixtures for models translations in a Rails app using Mobility?
Currently, I have the following directory structure:
π test
π fixtures
π article
π translations.yml
π articles.yml
# test/fixtures/articles.yml
past_article:
type: BlogPost
author: Barney Rubble
posted_on: <%= 5.days.ago.to_s(:db) %>
hero_image_id: 1
# test/fixtures/article/translations.yml
past_article_translation:
article: past_article
locale: en
title: Past Article Fixture
subtitle: Temporary subtitle
body: This is the temporary blog post content.
I get ActiveRecord::Fixture::FixtureError: table "article_translations" has no column named "article".
when trying to run my tests.
With Globalize gem, I could change the key in translations.yml
from article
to globalized_model
, but that doesn't work with Mobility.
If you change article
to translated_model
, I believe it should work. translated_model
is the equivalent in Mobility to globalized_model
in Globalize.
(I don't use fixtures myself so not really familiar with syntax, but the inverse relationship from translation to model is translated_model
, which you can see here).