Just launched! Get 30% off Rails Revisited Have a Look

Using Scaffold With Existing Data

Buy or Subscribe

You can access this course in just a minute, and support my efforts to rid the world of crappy online courses!

Buy Standalone  Subscribe

There are two ways to work with Rails' scaffolds. You can create one with a name and the fields that you need:
rails g scaffold customer first_name last_name email:uniq company address city state country 
postal_code phone fax  --no-migration --no-jbuilder
And you can destroy what you've done by using destroy:
rails destroy scaffold customer
I created a scripts directory with two scaffold files in there as I found that I would create a scaffold, need to add some data or schema changes, and then redo it. This happened often, and so I made sure I knew what I was doing by recording the scaffolds in these tables.

Flexing Magical Rails Restful Routes

The "Big 7" in Rails are index show edit new create update delete. When you scaffold a resource, these routes (and their views) are generated for you, and all you need to do is alter them to suit your needs. This is mostly with the index and show routes, which the user will see (if you let them). The other routes are for admins to manipulate the data.