Nick Sieger: RailsConf: Amy Hoy - Overcoming Scaffolding Addiction http://blog.nicksieger.com/articles/2006/06/23/railsconf-amy-hoy-scaffolding en-us 40 do what you love RailsConf: Amy Hoy - Overcoming Scaffolding Addiction <p>Scaffolding is not a swiss army knife, it&#8217;s more like a rusty spoon. It&#8217;ll give you tetanus! Scaffolding leads to brain atrophy and laziness. Leads to bad code, bad UI, etc. Instead, start from scratch. <code>script/generate</code> is not inherently bad, it can write necessary, tedious code for you.</p> <pre><code>script/generate controller kitten create view put_to_sleep </code></pre> <p>This gives you:</p> <div class="typocode"><pre><code class="typocode_ruby "><span class="keyword">class </span><span class="class">KittenController</span> <span class="punct">&lt;</span> <span class="constant">ApplicationController</span> <span class="keyword">def </span><span class="method">create</span> <span class="keyword">end</span> <span class="keyword">def </span><span class="method">view</span> <span class="keyword">end</span> <span class="keyword">def </span><span class="method">put_to_sleep</span> <span class="keyword">end</span> <span class="keyword">end</span></code></pre></div> <p>Amy proceeds to break down a from-scratch, minimalist set of views, to underscore the point that it&#8217;s not too hard to not use scaffolding. I&#8217;d agree, it was so straightforward that unfortunately I&#8217;m going to omit the details here. Rolling your own without scaffolding is highly recommended.</p> <p>Some of the items that you generally will experience in real world apps but do not come in scaffolding are widgets for maintaining relationships. Select lists based on a <code>belongs_to</code>, checkbox groups for <code>has_many</code> are two examples.</p> <p>Amy breaks these down as well and it turns out they&#8217;re pretty easy to do. One snippet of code for updating checkboxes was succinct and surprisingly readable, and made judicious use of the ruby array&#8217;s <code>-</code> behavior to add newly checked and remove newly unchecked items quickly.</p> <p>Amy promised to post snippets and slides later on her blog, so go over to <a href="http://www.slash7.com/">slash7</a> for more.</p> Fri, 23 Jun 2006 21:43:00 +0000 urn:uuid:c75b0ef7-57f2-4856-9713-776cdef0bf23 Nick Sieger http://blog.nicksieger.com/articles/2006/06/23/railsconf-amy-hoy-scaffolding ruby rails railsconf http://blog.nicksieger.com/articles/trackback/25