RailsConf: Amy Hoy - Overcoming Scaffolding Addiction

Posted by Nick Sieger Fri, 23 Jun 2006 21:43:00 GMT

Scaffolding is not a swiss army knife, it’s more like a rusty spoon. It’ll give you tetanus! Scaffolding leads to brain atrophy and laziness. Leads to bad code, bad UI, etc. Instead, start from scratch. script/generate is not inherently bad, it can write necessary, tedious code for you.

script/generate controller kitten create view put_to_sleep

This gives you:

class KittenController < ApplicationController

  def create

  def view

  def put_to_sleep

Amy proceeds to break down a from-scratch, minimalist set of views, to underscore the point that it’s not too hard to not use scaffolding. I’d agree, it was so straightforward that unfortunately I’m going to omit the details here. Rolling your own without scaffolding is highly recommended.

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 belongs_to, checkbox groups for has_many are two examples.

Amy breaks these down as well and it turns out they’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’s - behavior to add newly checked and remove newly unchecked items quickly.

Amy promised to post snippets and slides later on her blog, so go over to slash7 for more.

Posted in ,  | Tags  | no comments | no trackbacks



Use the following link to trackback from your own site: