Em 27-04-2012 13:47, Jeremy Evans escreveu:
On Friday, April 27, 2012 9:23:13 AM UTC-7, Rodrigo Rosenfeld Rosas wrote:

    I can get the sandbox information through
    "Rails.application.sandbox?". Could you give an example on how to
    use this Sequel's "after_connect" hook to ensure it will be inside
    a transaction?


  DB.pool.after_connect = proc do |conn|
    DB.send(:add_transaction, conn, {})
    DB.send(:begin_transaction, conn, {})
  end
  DB.disconnect # remove existing connections

I'd just like to report you that this made the trick for me.

Thanks.

There is one gotcha though: Rails.application.sandbox? will be always nil inside an initializer, so I had to check for the argument in ARGV.

I've updated my article to reflect what I've done:

http://rosenfeld.herokuapp.com/en/articles/2012-04-18-getting-started-with-sequel-in-rails

And as a nice side-effect, if I changed my mind in the middle of the console session I could just issue a COMMIT by myself ;)

Best,
Rodrigo.

--
You received this message because you are subscribed to the Google Groups 
"sequel-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/sequel-talk?hl=en.

Reply via email to