正如我所解釋的,我想基於用戶使用不同的數據庫。如何在database.yml中創建if語句以使用基於rails中當前用戶的不同數據庫
我得到了一個用devise創建的合作伙伴表,我有多個我創建的數據庫。這些數據庫的每個人都有相同的模式和相同的關係。
什麼,我想完成的是一樣的東西
default: &default
adapter: mysql2
pool: 5
timeout: 5000
development:
<<: *default
database: db_ <%= current_partners%>
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: db_ <%= current_partners%>
production:
<<: *default
database: db_ <%= current_partners%>
爲什麼我不能用這個說法?
順便說一句我使用mysql2中看到的代碼片段。
我確實有一個合作伙伴模型,但我會有巨大的表格,我希望它們能夠更快,更快地響應查詢。我該如何使用它? – railsnewbie 2014-08-30 16:53:51
只需將foreign_keys索引到合作伙伴模型,並且全部將非常快速。 – BroiSatse 2014-08-30 17:01:32