1

如何使用 Mobility 在 Rails 应用程序中为模型翻译设置固定装置?

目前,我有以下目录结构:

 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.

ActiveRecord::Fixture::FixtureError: table "article_translations" has no column named "article".在尝试运行测试时得到。

使用 Globalize gem,我可以将密钥translations.yml从更改articleglobalized_model,但这不适用于 Mobility。

4

1 回答 1

2

如果您更改articletranslated_model,我相信它应该可以工作。translated_model相当于移动性globalized_model中的全球化。

(我自己不使用固定装置,所以对语法不是很熟悉,但是从翻译到模型的反比关系是translated_model,你可以在这里看到)。

于 2018-02-13T11:09:28.063 回答