<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Efficiently Incrementing Model Attribute Values</title>
	<atom:link href="http://www.railsrocket.com/efficiently-incrementing-model-attribute-values/feed" rel="self" type="application/rss+xml" />
	<link>http://www.railsrocket.com/efficiently-incrementing-model-attribute-values</link>
	<description>A Ruby on Rails community website with tutorials</description>
	<lastBuildDate>Thu, 25 Mar 2010 23:45:08 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: ashes999</title>
		<link>http://www.railsrocket.com/efficiently-incrementing-model-attribute-values/comment-page-1#comment-2837</link>
		<dc:creator>ashes999</dc:creator>
		<pubDate>Tue, 16 Jun 2009 16:47:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.railsrocket.com/articles/?p=23#comment-2837</guid>
		<description>@Nathan, thanks, that&#039;s very interesting; I haven&#039;t really used Rails 2.3, but I&#039;ll definitely look up this new method.</description>
		<content:encoded><![CDATA[<p>@Nathan, thanks, that&#8217;s very interesting; I haven&#8217;t really used Rails 2.3, but I&#8217;ll definitely look up this new method.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nathan</title>
		<link>http://www.railsrocket.com/efficiently-incrementing-model-attribute-values/comment-page-1#comment-2832</link>
		<dc:creator>Nathan</dc:creator>
		<pubDate>Mon, 15 Jun 2009 19:19:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.railsrocket.com/articles/?p=23#comment-2832</guid>
		<description>I would recommend using the update_counters method.

In my case, my entity, Page, had an updated_at column, which Rails automatically updates anytime a record is saved. I wanted to maintain a view_count, but I didn&#039;t want the updated_at attribute to be changed each time the view_count was incremented. I used update_counters to achieve this.

In my &#039;show&#039; action:


Page.update_counters(params[:id], :view_count =&gt; 1)
@page = Page.find(params[:id]


The update_counters method automatically saves the record and skips the automagic timestamp updates. 

This works for Rails 2.3.2</description>
		<content:encoded><![CDATA[<p>I would recommend using the update_counters method.</p>
<p>In my case, my entity, Page, had an updated_at column, which Rails automatically updates anytime a record is saved. I wanted to maintain a view_count, but I didn&#8217;t want the updated_at attribute to be changed each time the view_count was incremented. I used update_counters to achieve this.</p>
<p>In my &#8216;show&#8217; action:</p>
<p>Page.update_counters(params[:id], :view_count =&gt; 1)<br />
@page = Page.find(params[:id]</p>
<p>The update_counters method automatically saves the record and skips the automagic timestamp updates. </p>
<p>This works for Rails 2.3.2</p>
]]></content:encoded>
	</item>
</channel>
</rss>

