ruby-on-railsdatabaseruby-on-rails-4globalize

Rails defining database for globalize translations


I use globalize for translations in my Rails 4 App. I use two databases for my project. One for central data and one for local data. Now i want to establish a connection for my models translations. But I don't know how to doing this. I use an abstract class to establish the connections for my models, but how do i do this for the translation_tables? Problem:

My Abstract class:

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

My model with translation

class Additive < CentralBase
  translates :name
  ...
end

Solution

  • okay seems to be something like this:

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

    But a solution which put this line in the abstract class or something would be nice.