一次連接 Multi Database

看板Ruby作者 (lala)時間17年前 (2006/12/13 15:38), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串1/1
http://lightyror.blogspot.com/2006/12/multi-database.html andling with Rails。他們的作法有點詭異,而且有一個關鍵性的問題,每次 request 每個不相關的頁面也都得連接一次 external database。可是 Rails 要做這件事情應該沒那麼複雜呀? 1. 設定 config extradb_production: adapter: mysql host: localhost username: root password: blabla database: extradb_prod 2. 在相關 Model 利用 estabilish_connection 去做連接而外設定 class lala < ActiveRecord::Base establish_connection :extradb_production end 然後收工,連跨 DB 的關連性都沒問題。 -- lighty RoR 是一個介紹 lighttpd , SQLite , Ruby and Rails 的 Blog http://lightyror.blogspot.com/ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.218.90.242 ※ 編輯: giive 來自: 61.218.90.242 (12/13 15:38)

12/13 17:55, , 1F
這沒複製好吧 O_o
12/13 17:55, 1F
文章代碼(AID): #15VwtoZE (Ruby)