Seem's that i have one little question-trouble:
i have my rails application on server, let's say name A, and i use there all tables(let's say table1, table2).... But now i need to buy one more server, name B. And from there i must use some tables too (let's say table3, table4).
Is it really to use in rails two different db, from different server's? And how to do this? What to write than in ActiveModel files ?
Now i simple have database.yml with one db. How to set up some edit, as i say in question?
It is possible
In database YML:
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: app_development
pool: 5
username: root
password:
host: localhost
aux_development:
adapter: mysql2
encoding: utf8
reconnect: false
database: aux_development
pool: 5
username: root
password:
socket: /var/run/mysqld/mysqld.sock
All your models will use 'development' database. If you want one of them to use 'aux_development' just:
class OtherModel < ActiveRecord::Base
establish_connection "aux_#{Rails.env}"
end
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.