<?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: 5 Tips to Speed Up Your Rails App</title>
	<atom:link href="http://www.bencurtis.com/2007/08/5-tips-to-speed-up-your-rails-app/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bencurtis.com/2007/08/5-tips-to-speed-up-your-rails-app/</link>
	<description>Speculations on Web Development by Benjamin Curtis</description>
	<lastBuildDate>Fri, 27 Aug 2010 13:20:04 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Charlie</title>
		<link>http://www.bencurtis.com/2007/08/5-tips-to-speed-up-your-rails-app/comment-page-1/#comment-1160</link>
		<dc:creator>Charlie</dc:creator>
		<pubDate>Mon, 13 Aug 2007 23:38:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.bencurtis.com/archives/2007/08/5-tips-to-speed-up-your-rails-app/#comment-1160</guid>
		<description>Hi Ben - Nice article, and thanks for the plug.  Glad to hear that ruby-prof has been useful.  Do you have the before and after performance numbers for your changes?  I&#039;m trying to put together a few examples of successful use of ruby-prof, so any data you can provide would be great.  Feel free to email me if you&#039;d rather not post online.</description>
		<content:encoded><![CDATA[<p>Hi Ben &#8211; Nice article, and thanks for the plug.  Glad to hear that ruby-prof has been useful.  Do you have the before and after performance numbers for your changes?  I&#8217;m trying to put together a few examples of successful use of ruby-prof, so any data you can provide would be great.  Feel free to email me if you&#8217;d rather not post online.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: EmmanuelOga</title>
		<link>http://www.bencurtis.com/2007/08/5-tips-to-speed-up-your-rails-app/comment-page-1/#comment-1158</link>
		<dc:creator>EmmanuelOga</dc:creator>
		<pubDate>Mon, 13 Aug 2007 04:19:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.bencurtis.com/archives/2007/08/5-tips-to-speed-up-your-rails-app/#comment-1158</guid>
		<description>My comment was supposed to read as (i hope this times it gets right :):

class App &lt; ActiveRecord::Base

def find_or_create_by_name(name)
   App.find(:first, :conditions =&gt; [â€˜name = ?â€™, name]) &#124;&#124; 
   App.create(:name =&gt; name)
end

end
</description>
		<content:encoded><![CDATA[<p>My comment was supposed to read as (i hope this times it gets right :):</p>
<p>class App &lt; ActiveRecord::Base</p>
<p>def find_or_create_by_name(name)<br />
   App.find(:first, :conditions =&gt; [â€˜name = ?â€™, name]) ||<br />
   App.create(:name =&gt; name)<br />
end</p>
<p>end</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: EmmanuelOga</title>
		<link>http://www.bencurtis.com/2007/08/5-tips-to-speed-up-your-rails-app/comment-page-1/#comment-1157</link>
		<dc:creator>EmmanuelOga</dc:creator>
		<pubDate>Mon, 13 Aug 2007 04:16:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.bencurtis.com/archives/2007/08/5-tips-to-speed-up-your-rails-app/#comment-1157</guid>
		<description></description>
		<content:encoded><![CDATA[<p>instead of </p>
<p>â€œApp.find_or_create_by_name(name)â€?, </p>
<p>use </p>
<p>â€œApp.find(:first, :conditions =&gt; [â€˜name = ?â€™, name]) || App.create(:name =&gt; name)</p>
<p>Why not defining the methods you use the most in your models?? That why you can still use them in controllers, retaininig readability and also do it effciiently:</p>
<p>class App  [â€˜name = ?â€™, name]) ||<br />
  App.create(:name =&gt; name<br />
end</p>
<p>end</p>
<p>That would not call method_missing anymore!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: BenCurtis.com Â» 5 Tips to Speed Up Your Rails App - &#8216;all the knowledge you can eat&#8217;</title>
		<link>http://www.bencurtis.com/2007/08/5-tips-to-speed-up-your-rails-app/comment-page-1/#comment-1155</link>
		<dc:creator>BenCurtis.com Â» 5 Tips to Speed Up Your Rails App - &#8216;all the knowledge you can eat&#8217;</dc:creator>
		<pubDate>Sat, 11 Aug 2007 00:01:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.bencurtis.com/archives/2007/08/5-tips-to-speed-up-your-rails-app/#comment-1155</guid>
		<description>[...] &#187; 5 Tips to Speed Up Your Rails App     No Comments   Leave a Commenttrackback addressThere was an error with your comment, please try again. name (required)email (will not be published)(required)url [...]</description>
		<content:encoded><![CDATA[<p>[...] &raquo; 5 Tips to Speed Up Your Rails App     No Comments   Leave a Commenttrackback addressThere was an error with your comment, please try again. name (required)email (will not be published)(required)url [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jake varghese</title>
		<link>http://www.bencurtis.com/2007/08/5-tips-to-speed-up-your-rails-app/comment-page-1/#comment-1154</link>
		<dc:creator>jake varghese</dc:creator>
		<pubDate>Fri, 10 Aug 2007 17:12:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.bencurtis.com/archives/2007/08/5-tips-to-speed-up-your-rails-app/#comment-1154</guid>
		<description>Here&#039;s another tip i found useful.

When you have a collection of records that you want iterate over for some reason or another, dont use the methods, use the attributes hash.

Example:
Let&#039;s say that you have collection of models and you want to get the IDs of those models into an array.
Usually, you have a couple of choices:
1. Pure SQL: basically add a :select option to your finder to only select the IDs, this is ok if all you need are the IDs, but what if you need the IDs in one place (for some sort of checking or other logic) and youalso needed the rest of the information?

2.  Quick ruby mappage:  All of us have seen this beautifully simple code at least once:
@objects.map {&#124;e&#124; e.id}
Unfortnuately, this code creates a SQL call for every model, very expensive.

3.  Almost quick ruby mappage:
Almost as beautiful and way faster:
@objects.map {&#124;e&#124; e.attributes[&quot;id&quot;]}


peace

jake</description>
		<content:encoded><![CDATA[<p>Here&#8217;s another tip i found useful.</p>
<p>When you have a collection of records that you want iterate over for some reason or another, dont use the methods, use the attributes hash.</p>
<p>Example:<br />
Let&#8217;s say that you have collection of models and you want to get the IDs of those models into an array.<br />
Usually, you have a couple of choices:<br />
1. Pure SQL: basically add a :select option to your finder to only select the IDs, this is ok if all you need are the IDs, but what if you need the IDs in one place (for some sort of checking or other logic) and youalso needed the rest of the information?</p>
<p>2.  Quick ruby mappage:  All of us have seen this beautifully simple code at least once:<br />
@objects.map {|e| e.id}<br />
Unfortnuately, this code creates a SQL call for every model, very expensive.</p>
<p>3.  Almost quick ruby mappage:<br />
Almost as beautiful and way faster:<br />
@objects.map {|e| e.attributes["id"]}</p>
<p>peace</p>
<p>jake</p>
]]></content:encoded>
	</item>
</channel>
</rss>
