What does “scaffold” mean in Ruby on Rails?
I'm also studying Ruby On Rails, and here is how I remember it:
- Each scaffold is an object inside your application, that users will interact with. Users can create this object, update, read or delete it.
- At Facebook, one of these objects is status. Each user can create it, read, delete or update status.
- On Twitter, it's tweet.
- At Pinterest, it's pins.
Every application contains many such objects — statuses, photos, comments, users, etc. You have to plan all of them and design future interactions between these objects and users of your application.
In rails 3.2 when you type this in the TERMINAL, inside your rails app folder:
rails generate scaffold User
the "User" part could be any name you choose...
it creates all of the the structure for your CRUD (create, read, update, delete)
in this creation it includes the controller, model, and views the views for each part of the CRUD (create, read, update, delete),
and the code inside them to start you off with your CRUD (create, read, update, delete)
its way easier to do this, instead of coding everything yourself, it saves you lots of time!
see rails guide for the explanation
Rails scaffolding is a quick way to generate some of the major pieces of an application. If you want to create the models, views, and controllers for a new resource in a single operation, scaffolding is the tool for the job.
Scaffolding in Ruby on Rails refers to the auto generation of a simple set of a model, views and controller usually for a single table.
For example:
user@localhost$ ./scripts/generate scaffold users
Would create a full CRUD (create, read, update, delete) web interface for the Users table. Of course features like hashing the password, uploading images, etc... are not handled and must be added to the auto-generated code.