<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>PMA Media Group&#187; activerecord</title>
	<atom:link href="http://www.pmamediagroup.com/tag/activerecord/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.pmamediagroup.com</link>
	<description>Unique Marketing Techniques and Strategies with Guaranteed Results!</description>
	<lastBuildDate>Thu, 29 Jul 2010 15:34:44 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>You Don&#8217;t Need Custom SQL For Simple Aggregation Using ActiveRecord</title>
		<link>http://www.pmamediagroup.com/2009/04/you-dont-need-custom-sql-for-simple-aggregation-using-activerecord/</link>
		<comments>http://www.pmamediagroup.com/2009/04/you-dont-need-custom-sql-for-simple-aggregation-using-activerecord/#comments</comments>
		<pubDate>Thu, 02 Apr 2009 19:36:04 +0000</pubDate>
		<dc:creator>Aaron Murphy</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[activerecord]]></category>
		<category><![CDATA[average]]></category>
		<category><![CDATA[count]]></category>
		<category><![CDATA[maximum]]></category>
		<category><![CDATA[minimum]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[sum]]></category>

		<guid isPermaLink="false">http://www.pmamediagroup.com/?p=195</guid>
		<description><![CDATA[ActiveRecord allows one to execute an SQL statement directly. I prefer to avoid any ActiveRecord code that uses too much SQL syntax. This way I won&#8217;t have to rework any code if the underlying database engine was changed.  Some of the simple SQL functions that one may want to do with SQL syntax might [...]]]></description>
			<content:encoded><![CDATA[<p>ActiveRecord allows one to execute an SQL statement directly. I prefer to avoid any ActiveRecord code that uses too much SQL syntax. This way I won&#8217;t have to rework any code if the underlying database engine was changed.  Some of the simple SQL functions that one may want to do with SQL syntax might be SUM, AVG, COUNT, etc. With <a href="http://api.rubyonrails.org/classes/ActiveRecord/Calculations/ClassMethods.html">ActiveRecord::Calculations::ClassMethods</a>, one can avoid specialized syntax.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;">#returns the total count of all people</span>
Person.<span style="color:#9900CC;">count</span>
<span style="color:#008000; font-style:italic;"># returns the total count of all people with an age over 26</span>
Person.<span style="color:#9900CC;">count</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:conditions</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;age &gt; 26&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></td></tr></table></div>

<p>The following methods are available: <strong>average, count, maximum, minimum, sum</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pmamediagroup.com/2009/04/you-dont-need-custom-sql-for-simple-aggregation-using-activerecord/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Foreign Key Migrations Plugin</title>
		<link>http://www.pmamediagroup.com/2009/04/foreign-key-migrations-plugin/</link>
		<comments>http://www.pmamediagroup.com/2009/04/foreign-key-migrations-plugin/#comments</comments>
		<pubDate>Thu, 02 Apr 2009 16:33:51 +0000</pubDate>
		<dc:creator>Chuck Wood</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[activerecord]]></category>
		<category><![CDATA[migrations]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.pmamediagroup.com/?p=256</guid>
		<description><![CDATA[I worked on a plugin yesterday that would include all of our migration helpers. You can find it on github. Currently, it only does foreign keys work, but eventually, I&#8217;d like to have it add unique indexes on columns defined with a :unique =&#62; true attribute in the ActiveRecord migration. But for right now, here&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>I worked on a plugin yesterday that would include all of our migration helpers. You can find it on <a href="http://github.com/woody2shoes/migration_helpers/tree/master">github</a>. Currently, it only does foreign keys work, but eventually, I&#8217;d like to have it add unique indexes on columns defined with a :unique =&gt; true attribute in the ActiveRecord migration. But for right now, here&#8217;s how to use it:</p>
<p>Adding a foreign key that references the id column in another table:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;"># The column 'id' is assumed in the referenced table.</span>
add_foreign_key <span style="color:#ff3333; font-weight:bold;">:table1</span>, <span style="color:#ff3333; font-weight:bold;">:table2_ref</span>, <span style="color:#ff3333; font-weight:bold;">:table2</span></pre></div></div>

<p><span id="more-256"></span></p>
<p>Adding a foreign key that references the name column in another table:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">add_foreign_key <span style="color:#ff3333; font-weight:bold;">:table1</span>, <span style="color:#ff3333; font-weight:bold;">:table2_name</span>, <span style="color:#ff3333; font-weight:bold;">:table2</span>, <span style="color:#ff3333; font-weight:bold;">:name</span></pre></div></div>

<p>Removing a foreign key with a custom name for the SQL constraint:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">drop_foreign_key <span style="color:#ff3333; font-weight:bold;">:table1</span>, <span style="color:#996600;">&quot;table1_ref_to_table2&quot;</span></pre></div></div>

<p>Removing a foreign key with no custom name for the SQL constraint:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">drop_foreign_key <span style="color:#ff3333; font-weight:bold;">:table1</span>, <span style="color:#ff3333; font-weight:bold;">:table2_ref</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.pmamediagroup.com/2009/04/foreign-key-migrations-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ActiveRecord Destroy vs. Delete</title>
		<link>http://www.pmamediagroup.com/2009/04/activerecord-destroy-vs-delete/</link>
		<comments>http://www.pmamediagroup.com/2009/04/activerecord-destroy-vs-delete/#comments</comments>
		<pubDate>Thu, 02 Apr 2009 16:11:22 +0000</pubDate>
		<dc:creator>Chuck Wood</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[activerecord]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://www.pmamediagroup.com/?p=252</guid>
		<description><![CDATA[I&#8217;ve been reading &#8220;Pro ActiveRecord&#8221; by Kevin Marshall, Chad Pytel, and Jon Yurek. They explained in the book the difference between the delete and destroy methods, which is something I had never really seen clarified anywhere. I&#8217;ve discussed it with several Rails developers and have gotten varying opinions.

Here&#8217;s what I&#8217;ve come to understand. The destroy [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been reading &#8220;Pro ActiveRecord&#8221; by Kevin Marshall, Chad Pytel, and Jon Yurek. They explained in the book the difference between the delete and destroy methods, which is something I had never really seen clarified anywhere. I&#8217;ve discussed it with several Rails developers and have gotten varying opinions.</p>
<p><span id="more-252"></span></p>
<p>Here&#8217;s what I&#8217;ve come to understand. The destroy method makes the SQL call to the database and destroys the row in the table that contains it. It does still allow you to manipulate the object in the application as long as it&#8217;s still in scope.</p>
<p>The delete method also makes the SQL call, but freezes the object so you cannot make changes to it. It also doesn&#8217;t make the before_destroy and after_destroy callbacks.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pmamediagroup.com/2009/04/activerecord-destroy-vs-delete/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/


Served from: www.pmamediagroup.com @ 2010-07-31 10:43:45 -->