<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>has_many :thoughts: The Rails Way</title>
    <link>http://blog.kineticweb.com/articles/2007/05/21/the-rails-way</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Musings from a Ruby on Rails development team</description>
    <item>
      <title>The Rails Way</title>
      <description>&lt;p&gt;Sunday&amp;#8217;s morning keynote at RailsConf was by Jamis Buck and Michael Koziarrski, both committers to the Rails core. The format was quite useful: a series of short code reviews from a variety of submitters to their website, &lt;a href="http://www.therailsway.com"&gt;The Rails Way&lt;/a&gt;.&lt;/p&gt;


	&lt;ol&gt;
	&lt;li&gt;Jamis asked for a show of hands for who had read his &#8220;Skinny Controller / Fat Model&#8221; article. I, ashamedly, have not, but I intend to. I&amp;#8217;ve heard the &#8220;fat model&#8221; concept more and have been trying to emphasize putting as much as makes sense into the Model, and less into the controller.&lt;/li&gt;
	&lt;/ol&gt;


	&lt;ol&gt;
	&lt;li&gt;They mentioned how you can override the &lt;code&gt;#to_param&lt;/code&gt; method on an ActiveRecorded descendant in order to control what is used as the &#8220;id&#8221; string when building a &lt;span class="caps"&gt;URL&lt;/span&gt; in Rails. This would work perfectly with the pretty URLs I have been trying to use more and more.&lt;/li&gt;
	&lt;/ol&gt;


	&lt;ol&gt;
	&lt;li&gt;Jamis stresses how we should all strive to make our code &#8220;intention revealing&#8221;.  One of the beauties of Ruby is the flexibility and expressiveness it allows you. Wherever possible, we should structure our code to be readable and even self-documenting. And where our code does not clearly reveal our intentions, we should document liberally with comments.&lt;/li&gt;
	&lt;/ol&gt;


	&lt;ol&gt;
	&lt;li&gt;&lt;code&gt;#with_options&lt;/code&gt; seems to be a pretty slick little method that I have to try. It&amp;#8217;s a method on Object that allows you to prevent repeating the same options on a series of method calls.&lt;/li&gt;
	&lt;/ol&gt;


	&lt;ol&gt;
	&lt;li&gt;Many people forget to actually use the ActiveRecord associations they setup. For instance, instead of &lt;code&gt;People.find(:all, :conditions =&amp;gt; [&#8220;company_id = ?&#8221;, 99])&lt;/code&gt; one can do something like &lt;code&gt;@company.people&lt;/code&gt; which can make your code much more readable and DRYer, too.&lt;/li&gt;
	&lt;/ol&gt;


	&lt;ol&gt;
	&lt;li&gt;And finally, they showed a code example that used the &lt;code&gt;#returning&lt;/code&gt; method wrapped around several lines of code in a method that was to return something. Even after an explanation, I didn&amp;#8217;t quite get how this worked. So that&amp;#8217;s something to investigate.&lt;/li&gt;
	&lt;/ol&gt;</description>
      <pubDate>Mon, 21 May 2007 11:01:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:c2663f49-3271-4ab6-ac1e-dd5e17221516</guid>
      <author>Colin A. Bartlett</author>
      <link>http://blog.kineticweb.com/articles/2007/05/21/the-rails-way</link>
      <category>Rails</category>
      <category>ruby</category>
      <category>RailsConf</category>
      <category>RailsConf07</category>
    </item>
  </channel>
</rss>
