mardi 17 mars 2015

how to create model from different databases?

I just started learning ROR. And came across this DOUBT.


I have defined multiple databases in my



database.yml



file. Like this



development:
adapter: mysql2
encoding: utf8
reconnect: true
database: mydb1
username: root
password: root
host: localhost

custom:
adapter: mysql2
encoding: utf8
reconnect: true
database: customdb
username: root
password: root
host: localhost


Now if i create a model usig rails generate model MyModel it will create a migration script to generate a table called my_modles in mydb1.


My question is "How can i create/specify a model, that to create a table under customdb?"


Do i need to change my rails environment or is there are any other ways. I am just curious. I can do this manually by creating a table in customdb and creating a model without migration.


Aucun commentaire:

Enregistrer un commentaire