<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Rails Forum - Ruby on Rails Help and Discussion Forum - Override method in class]]></title>
		<link>http://railsforum.com/viewtopic.php?id=50062</link>
		<description><![CDATA[The most recent posts in Override method in class.]]></description>
		<lastBuildDate>Sat, 25 Aug 2012 16:51:00 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Override method in class]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=154876#p154876</link>
			<description><![CDATA[<p>Hi,</p><p>The code below shows an attempt to override begin and commit_db_transaction in ActiveRecord. However, this doesn&#039;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.</p><p>What am I doing wrong? The code below is part of a plugin that I&#039;ve created. I&#039;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.</p><p>module ActiveRecord<br />&nbsp; module ConnectionAdapters&nbsp; &nbsp; <br />&nbsp; &nbsp; class AbstractMysqlAdapter &lt; AbstractAdapter<br />&nbsp; &nbsp; &nbsp; alias_method :original_begin_db_transaction, :begin_db_transaction<br />&nbsp; &nbsp; &nbsp; alias_method :original_commit_db_transaction, :commit_db_transaction</p><p>&nbsp; &nbsp; &nbsp; def begin_db_transaction<br />&nbsp; &nbsp; &nbsp; &nbsp; original_begin_db_transaction unless xa_transaction_in_progress?<br />&nbsp; &nbsp; &nbsp; end</p><p>&nbsp; &nbsp; &nbsp; def commit_db_transaction<br />&nbsp; &nbsp; &nbsp; &nbsp; original_commit_db_transaction unless xa_transaction_in_progress?<br />&nbsp; &nbsp; &nbsp; end<br />&nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; end<br />&nbsp; end<br />end</p>]]></description>
			<author><![CDATA[dummy@example.com (lespaul86)]]></author>
			<pubDate>Sat, 25 Aug 2012 16:51:00 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=154876#p154876</guid>
		</item>
	</channel>
</rss>
