A quick post for today.
Want to get rid of transactions from ActiveRecord for something? Here's a cheap way to do it.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Force the loading of AR stuff | |
ActiveRecord::Base.connection.execute('SELECT 1') | |
# Remove transactions from MySQL adapter | |
ActiveRecord::ConnectionAdapters::MysqlAdapter.class_eval do | |
def begin_db_transaction | |
end | |
def commit_db_transaction | |
end | |
end |
It only works for MySQL obviously, but you can roll your own if you are on postgres. I'll make it a bit less crappy and make it a gem or something.