[LRUG] Handling opening and closing of transactions manually in ActiveRecord
Tim Cowlishaw
tim at timcowlishaw.co.uk
Fri Oct 8 04:28:29 PDT 2010
On Fri, Oct 8, 2010 at 12:20 PM, Murray Steele <murray.steele at gmail.com> wrote:
> It looks like you'd need to spin up a
> block-less version of
> active_record/connection_adapters/abstract/database_statements.rb
> #transaction (rails 2.3.x). Could be painful because that method 'aint
> simple.
Yep - exactly what I suspected - to be honest, I think it seems like a
massive amount of work (and potential brittleness) for very little
reward, so I might leave that idea by the wayside for the time being.
> However. I wonder. If you're on 1.9 could something cunning be done with
> Fibers being passed into the block form of transaction ?
Heh, yes, excellent idea, but we're still .on 1.8.7 over here :-(
> However(again) might it be easier to just:
> Before(:all) do
> # create whatever
> end
> After(:all) do
> # destroy whatever
> # or
> # use database_cleaner to truncate the DB
> end
I think that's probably the best idea to be honest, at least then
we're being more explicit about when setup and teardown happens,
rather than hacking rspec to have non-standard semantics, potentially
opening ourselves up to a load of confusion and pain in the process.
Will get to writing those After(:all) blocks!
Cheers,
Tim
More information about the Chat
mailing list