如何使用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,但这不适用于移动性。
发布于 2018-02-13 19:09:28
如果您将article更改为translated_model,我相信它应该可以工作。在全球化中,translated_model等同于globalized_model的移动性。
(我自己不使用fixture,所以对语法不是很熟悉,但是从转换到模型的反向关系是translated_model,您可以看到here)。
https://stackoverflow.com/questions/48758339
复制相似问题