From 67fd679dd5cfc3ba2c49a2fff01505f1783275ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Linhares?= Date: Sun, 8 Nov 2009 22:59:56 -0300 Subject: [PATCH] Apply fixes suggested by http://github.com/deepak-srishti --- README | 2 +- lib/master_slave_adapter/adapter.rb | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/README b/README index 3f02741..a6cbd05 100644 --- a/README +++ b/README @@ -21,7 +21,7 @@ end To use this adapter you just have to install the plugin: -ruby script/plugin install git://github.com/mauricio/master_database_adapter.git +ruby script/plugin install git://github.com/mauricio/master_slave_adapter.git And then configure it at your database.yml file: diff --git a/lib/master_slave_adapter/adapter.rb b/lib/master_slave_adapter/adapter.rb index 972c85d..85c81ba 100644 --- a/lib/master_slave_adapter/adapter.rb +++ b/lib/master_slave_adapter/adapter.rb @@ -85,11 +85,15 @@ def test_connections class << self def with_master - enable_master - begin + if master_enabled? yield - ensure - disable_master + else + enable_master + begin + yield + ensure + disable_master + end end end