How do I disable transactions in Rails' ActiveRecord? I have a specific situation where I want them to go away I can't seem to find anything useful out there. Is it even possible?
A:
transaction is a class method on ActiveRecord::Base so you can do it like this:
Model.transaction do
...
end
or if you prefer to do it without a specific model:
ActiveRecord::Base.transaction do
...
end
It may also depend on which database you are using, I know for sure that works on mysql but not sure about others.
mcostanza
2010-04-20 23:07:03
You misread the question. I want to disable transactions, not use them. Your examples explicitly use transactions.ActiveRecord uses transactions at various points, and those are the ones I want to remove.
Daniel Huckstep
2010-04-20 23:29:04
Marked this one down for being irrelevant.
Greg Malcolm
2010-09-10 19:20:14
A:
Poor man's "no transactions"
# Force the loading of AR stuff
ActiveRecord::Base.connection.execute('SELECT 1')
# Remove transactions
ActiveRecord::ConnectionAdapters::MysqlAdapter.class_eval do
def begin_db_transaction
end
def commit_db_transaction
end
end
Daniel Huckstep
2010-04-20 23:30:54