RoR 4 - Connection to multiple databases

瀏覽次數:25 次
跳到第一則未讀訊息

Quake Live

未讀,
2015年9月29日 清晨5:05:092015/9/29
收件者:rubyonra...@googlegroups.com
Hi there,

is it somehow possible to connect from a running Rails4-app to another
database?

My problem is that I have to transfer records from a table from the main
database to a different database.

--
Posted via http://www.ruby-forum.com/.

Walter Lee Davis

未讀,
2015年9月29日 上午8:24:432015/9/29
收件者:rubyonra...@googlegroups.com

On Sep 29, 2015, at 5:04 AM, Quake Live <li...@ruby-forum.com> wrote:

> Hi there,
>
> is it somehow possible to connect from a running Rails4-app to another
> database?

Yes, I have done this in the past for migration reasons. You can create a different connection "long-hand" and get a specific model to use it. The last answer on this page (sadly zero-rated) has the solution I used. http://stackoverflow.com/questions/12379730/query-remote-database-from-rails-3-2-application

Walter

>
> My problem is that I have to transfer records from a table from the main
> database to a different database.
>
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/af0507fdd791af43902e56204e028af5%40ruby-forum.com.
> For more options, visit https://groups.google.com/d/optout.

jel...@gmail.com

未讀,
2015年9月29日 上午8:32:212015/9/29
收件者:rubyonra...@googlegroups.com
I actually ran into this same use case a couple of months back and using class abstraction did the trick beautifully.

Sent from my iPhone
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/099545A9-E6B4-443B-9041-37430D3A486C%40wdstudio.com.

Stewart Mckinney

未讀,
2015年9月29日 上午9:03:112015/9/29
收件者:rubyonra...@googlegroups.com
Try https://github.com/atombender/multidb as well. Very simple DSL and can be used for this stuff.

回覆所有人
回覆作者
轉寄
0 則新訊息