Multiple database connection in Rails

前端 未结 7 1244
说谎
说谎 2020-12-06 07:53

I\'m using active_delegate for multiple connection in Rails. Here I\'m using mysql as master_database for some models,and postgresql for some other models.

Problem i

7条回答
  •  佛祖请我去吃肉
    2020-12-06 08:27

    I tried ur Sample,still getting error!!

    superclass mismatch for class MysqlAdapter
    

    I think ,the problem is with my database.yml file .Please check this file

    database_mysql: 
      adapter: mysql
      database: project
      host: localhost
      username: root
      password: root
      port: 3306  
    
    development:
      adapter: postgresql
      database: codex
      host: localhost
      username: postgres
      password: root
      port: 5432  
    
    test:
      adapter: postgresql
      database: codex
      host: localhost
      username: postgres
      password: root
      port: 5432  
    
    production:
      adapter: postgresql
      database: codex
      host: localhost
      username: postgres
      password: root
      port: 5432  
    

    i start the mongrel in developemnet mode only.

    here is my model superclass

    $config = YAML.load_file(File.join(File.dirname(__FILE__),
       '../../config/database.yml'))
    
    class MasterDatabase < ActiveRecord::Base
        self.abstract_class = true
        establish_connection $config['database_mysql']    
    end 
    

    Please correct me..

提交回复
热议问题