Our First Scaffold

This is a premium course, which you can purchase below.

Buy Now

Rails is famous for its scaffolding system and was the very first thing DHH demo'd on stage all those years ago. Are they still useful? I think so! Let's see why.


Scaffolding is straightforward, but you'll want to be sure you check out your options:

rails g scaffold --help

I tend to avoid creating files I won't ever use because I hate visual clutter, but do whatever works for you, To that end, I will usually tell the scaffold to skip creating helpers and javascript nonsense:

rails g scaffold user name email:uniq --no-jbuilder --no-helper

Here, I'm telling Rails that our user has a name that's a string (the default) and same with email, but that the email should be unique (it's abbreviated in Ruby for some weird reason).

A note on helpers: they are very useful if you think you're going to create a page that will have some UI "logic" on it. My lesson page that shows videos, for instance, conditionally shows things based on whether someone is logged in and can access the video. That logic should be in a helper, not on your page.