如何使用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
中的密钥从article
更改为globalized_model
,但这不适用于Mobility。
答案 0 :(得分:1)
如果您将article
更改为translated_model
,我相信它应该可行。 translated_model
与全球化中的globalized_model
的移动性等效。
(我自己不使用灯具,所以不太熟悉语法,但从翻译到模型的反比关系是translated_model
,你可以看到here)。