Multiple DB connection in rails

前端 未结 3 1355
遇见更好的自我
遇见更好的自我 2021-02-10 06:43

I am trying to connect multiple database in ROR application.My database.yml is look like this in your database.yml file

development:

 adapter: mysql
 us         


        
3条回答
  •  盖世英雄少女心
    2021-02-10 07:17

    Thanks for reply.

    we can migrate a model for particular DB, for example

    db:migrate RAILS_ENV="portal_development"'.

    And more change for establishing connection with DB.check the corrected below

    class Test1Base < ActiveRecord::Base
      self.abstract_class = true
      establish_connection :development
    end
    
    class Test2Base < ActiveRecord::Base
      # No corresponding table in the DB.
      self.abstract_class = true
      establish_connection :portal_development
    end
    

    Thanks sameera for your valuable reply.

    cheers

    Shamith c

提交回复
热议问题