Calling Rake Tasks From Within Ruby Code

I need to call a rake task from within ruby code. I know that I can
just do something like this:

%x[rake my_rake_task]

But, I need to wrap this in an ActiveRecord transaction. Is there a way
to call a rake task w/o spawning a new process and thus gain the benefit
of wrapping it in an ActiveRecord transaction?

Sorry to ‘resurface’ this post, but I’d really like to know if anyone
has any ideas on this one?

Caleb wrote:

I need to call a rake task from within ruby code. I know that I can
just do something like this:

%x[rake my_rake_task]

But, I need to wrap this in an ActiveRecord transaction. Is there a way
to call a rake task w/o spawning a new process and thus gain the benefit
of wrapping it in an ActiveRecord transaction?

See Calling a task in rant at any time (not just as a prerequisi - Ruby - Ruby-Forum