开发者

Replacing / retrieving table from another database connection inside a model within Rails

Let's say I'm within a rails project in some model named Apple.

I'm going to switch databases to another server so I'll call: ActiveRecord::Base.establish_connection()

I want to access the table 'Banana' in this parti开发者_StackOverflow中文版cular database. I can see that the table exists by calling table_exists?

However, I'm not sure how to access the table... I want to just be able to do something like Banana.find(:all)

How should I work this out?


Have you tried connection_ninja gem? Pretty handy for multi-db connections:

https://github.com/cherring/connection_ninja

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜