Michael,

Yes, I'm making the connection in my model as you describe.  That is
working fine in the sense that it is connecting to the secondary
database.

My problem is, it appears to be connecting every time I instantiate
that object.  I've traced the entire establish_connection path, and it
appears to be creating a new ConnectionPool object each time.  What's
happening in establish_connection() is a little confusing to me.

As far as I can tell, there is no re-use of connections to the
secondary database.

Regarding my transactions, I'm doing it like this:

    prod.transaction do
      test.transaction do
        begin
          prod_result = prod.connection.execute(prod_sql)
          test_result = test.connection.execute(test_sql)
        rescue
          Util.lge "/// update exception"
          Util.lge "/// col_names = #{col_names.join(',')}"
          Util.lge "/// values = #{values.join(',')}"
          Util.lge "/// prod_sql = #{prod_sql}"
          Util.lge "/// test_sql = #{test_sql}"
          Util.lge "/// exception = #{$!}"
          raise ActiveRecord::Rollback
        end
      end
    end

My transaction code seems to work, but I need to test more failure
scenarios.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to