“Reads -> slaves, writes -> master” plugin
Another solution to multiple connections in Rails has been put together by the Revolution Health team.
Look at this sweet database.yml syntax:
dbs:
database: master_db
host: master-host
read_only:
database: slave_db
host: slave-host
ActsAsReadonlyable adds support of multiple read-only slave databases to ActiveRecord models. When a model is marked with acts_as_readonlyable, some of AR finders are overridden to run against a slave DB. The supported finders are find, find_by_sql, count_by_sql, find_[all_]by_*, and reload.
README all about it.
Trackbacks
Use this link to trackback from your own site.

Absolutely sweet, two solutions for a problem that started with a discussion not a week old. I was guessing that perhaps a big website as Revolution Health didn’t came by a similar problem than Twitter’s. You Magic Multi Connections and this ActsAsReadonlyable both goes by the same direction and they are fine. Yours expects an explicit conn proxy method - which I like. And Revolution’s approach is more transparent although we should be aware of any conflicts maybe with our own overwriting the finders and check out the logs to see if every finder is actually hitting the slaves. Anyhoo, congratulations for both authors for your creativity and quick response to the community.
[...] “Reads -> slaves, writes -> master” plugin Looks like the Ruby community is stepping up to tackle the scale problem. I hope they keep this development up and don’t just say “we fixed it”. [via Dirk] [...]
[...] Dr Nic » “Reads -> slaves, writes -> master” plugin (tags: rubyonrails database scaling) [...]