Rails为全球化翻译定义数据库

问题描述 投票:0回答:1

我在Rails 4 App中使用globalize进行翻译。我为我的项目使用了两个数据库。一个用于中央数据,一个用于本地数据。现在我想为我的模型翻译建立连接。但我不知道该怎么做。我使用抽象类来建立模型的连接,但是我如何为translation_tables做这个呢?问题:

  • 型号数据库:中央(正确)
  • 翻译数据库:local(wrong)

我的抽象类:

class CentralBase < ActiveRecord::Base
  establish_connection DB_CENTRAL
  self.abstract_class = true
end

我的模型有翻译

class Additive < CentralBase
  translates :name
  ...
end
ruby-on-rails database ruby-on-rails-4 globalize
1个回答
0
投票

好吧好像是这样的:

class Additive < CentralBase
  translates :name
  translation_class.establish_connection DB_Central
  ...
end

但是将这一行放在抽象类或其他东西中的解决方案会很好。

© www.soinside.com 2019 - 2024. All rights reserved.