The example in the previous chapter contained the key components you need to work with Rails and began to demonstrate how they work together. Rails is more than just a set of components, however—it’s a tightly knit package that includes tools to get you started more quickly. Rails can even teach you some best practices while making your work easier.
So, how do Rails developers build applications more quickly? One key piece of the puzzle is scaffolding. Instead of building a detailed controller and view, you can let Rails put up an interface to your data. In most cases, the scaffolding will be temporary, something you build on and replace, but in some cases the scaffolding may be enough to do what you need. The scaffolding also provides an excellent way to see what Rails’ creators think is a good way to accomplish common tasks.
If you’re wondering what happened to the instant one-line dynamic scaffolding that used to be a constant part of the Rails sales pitch, it’s gone. It disappeared in Rails 2.0, replaced by generated scaffolding that provides a much more solid foundation.
To get started, create a new application. Then create a model and
supporting scaffolding with a single command from the command line. Or,
if you’re in Heroku, go to the gear menu, choose Generate, and enter
scaffold Person name:string.
(You can also find all of these files in ch05/guestbook003.)
ruby script/generate scaffold ...