apartment gemを使用してマルチテナントアプリを作成しています。私はそれをすべてセットアップし、すべてが期待どおりに動作します。また、翻訳を保存するためにアクティブなレコードバックエンドを持つRails Internationalization(I18n)も使用しています。私の現在の設定アパートの宝石レール付き翻訳をロードしていません
変換テーブル
class CreateTranslations < ActiveRecord::Migration[5.0]
def change
create_table :translations do |t|
t.string :locale
t.string :key
t.text :value
t.text :interpolations
t.boolean :is_proc, default: false
t.timestamps
end
end
end
Apartment.rb構成
私は
すべてのテナント間でグローバルなので除外モデルのリストに翻訳モデルを追加しましたApartment.configure do |config|
# Add any models that you do not want to be multi-tenanted, but remain in the global (public) namespace.
# A typical example would be a Customer or Tenant model that stores each Tenant's information.
#
config.excluded_models = %w{ User Workspace Translation }
end
私の翻訳テーブルでは、英語(デフォルト)とノルウェー語の両方。メインドメインでは、すべてが英語とノルウェー語の切り替えが予想通りに行われますが、テナントがロードされるとすべての翻訳が失われます。コンソールでのデモ:
> Apartment::Tenant.switch! # switch to main tenant
> I18n.locale = :en # use English translations
> I18n.t('home.members_label')
=> "Show Members"
> Apartment::Tenant.switch! "elabs" # switch to a different tenant
> I18n.t('home.members_label')
=> "translation missing: en.home.members_label"
テナント環境ではなぜ翻訳が欠けているのかわかりません。私は、excluded_modelsのリストにある翻訳モデルがトリックを行うべきであると考えていましたが、何かが間違っているようです。すべての手がかりは?おかげ