Topic: Override method in class
The code below shows an attempt to override begin and commit_db_transaction in ActiveRecord. However, this doesn't work. The code in begin and commit_db_transaction of my extension is completely ignored and instead the original code in activerecord AbstractMysqlAdapter is executed.
What am I doing wrong? The code below is part of a plugin that I've created. I've added this plugin in the gemfile of rails test app in order to test my plugin. All other functionality of my plugin is working normally indicating that the code is loaded.
class AbstractMysqlAdapter < AbstractAdapter
alias_method :original_begin_db_transaction, :begin_db_transaction
alias_method :original_commit_db_transaction, :commit_db_transaction
original_begin_db_transaction unless xa_transaction_in_progress?
original_commit_db_transaction unless xa_transaction_in_progress?