Forum: Ruby on Rails SQLRelay adapter for Rails?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Eb2fbac0f7582bb1535edb1465073a95?d=identicon&s=25 jacqui (Guest)
on 2007-04-28 19:31
(Received via mailing list)
I would like to use SQLRelay for database connection pooling and query-
based routing with a Rails application that I am just about done with.
It is my first Rails project, and I thought it might be wise to get
some feedback on this before I get too far in coding it.

>From what I can tell, I am going to have to write a connection adapter
for ActiveRecord if I want to use SQLRelay (http:// with Rails. While I think this could be a
cool, fun and rewarding project, one that I will certainly be into
doing, time is of essence here (when isn't it?).

I was hoping someone on this list could add their two cents. I need
something like SQLRelay because the ops department, used to supporting
weighty, slow PHP apps, is refusing to put this Rails website out on
the Internet without support for DB pooling or at least read + write
databases. I'd like the application to respond quickly too, as that
will certainly play a large factor in whether or not the company
continues with Rails development. I've implemented caching as best as
I could, but I do still need to point at different databases, with
masters and slaves.

I am currently using acts_as_readonlyable, with some modifications, to
support a read-only database for my main database server.
Unfortunately, I had to use multiple database servers with this Rails
application (a member of my team wrote a plugin to support this along
the way), so the implementation of acts_as_readonlyable is less than

Advice is greatly appreciated. Have you written a connection adapter
for ActiveRecord? Or, better yet, have you implemented SQLRelay with

971708ecf1c0b3cada6cf98ea58611fd?d=identicon&s=25 Val (Guest)
on 2007-04-28 22:04
(Received via mailing list)

I hope somebody would answer your question about SQLRelay. Meanwhile,
I am not sure whether it helps in your situation, but as of 0.0.5,
ActsAsReadonlyable supports multiple slaves (picked at random for
every find). Just download the latest version from rubyforge and you
can use it as:

class Fruit < ActiveRecord::Base
  acts_as_readonlyable [:first_read_only, :second_read_only]

Eb2fbac0f7582bb1535edb1465073a95?d=identicon&s=25 jacqui (Guest)
on 2007-04-29 21:11
(Received via mailing list)
Thanks! That actually might help me. The problem I ran into with
acts_as_readonlyable was telling it to use different read_only
databases for different write databases. Like so:

  adapter: mysql
  database: my_development
  username: root
  encoding: utf8

    adapter: mysql
    database: my_development_slave
    username: root
    encoding: utf8

  adapter: mysql
  database: my_cms_development
  username: root
  encoding: utf8

    adapter: mysql
    database: my_cms_development_slave
    username: root
    encoding: utf8

acts_as_readonlyable didn't seem to work when some models had:

acts_as_readonlyable :read_only

and others had

acts_as_readonlyable :cms_read_only

The erroneous behavior I saw when I had two different read-only db
servers defined with different names was that the read only db servers
never got hit; all requests went to the write/master.

I'll try adding multiple read-only databases for the same master,
though, in an array. That is useful and will make things better on my
project - thanks!

- jacqui
This topic is locked and can not be replied to.