ubuntu, ror, jQuery, css, website memo
太嫩, 沒啥心得, 用來紀錄每天學的
2009年4月27日 星期一
ROR項目中連接多個數據庫的方法, abstract_class, establish_connection
ROR項目中連接多個數據庫的方法
如何連結到舊系統的資料庫
legacy_development:<br /># ...<br />legacy_test:<br /># ...<br />legacy_production:<br /># ...
<br />#就算是連到不同的database 也可以根據environment 而變<br />class LegacyClient < ActiveRecord::Base<br /> establish_connection "legacy_#{RAILS_ENV}"<br />end<br />
The self.abstract_class = true statements tell ActiveRecord that the LegacyDb classes cannot be instantiated themselves; since they represent database connections,they are not backed by concrete tables in the database
<br />class LegacyDb < ActiveRecord::Base<br />self.abstract_class = true<br />establish_connection "legacy_#{RAILS_ENV}"<br />end
<br />class LegacyClient < LegacyDb<br />end
沒有留言:
張貼留言
較新的文章
較舊的文章
首頁
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言