Ruby on Rails Getting started with Ruby on Rails Generate a Resource with Scaffolds


Example

From guides.rubyonrails.org:

Instead of generating a model directly . . . let's set up a scaffold. A scaffold in Rails is a full set of model, database migration for that model, controller to manipulate it, views to view and manipulate the data, and a test suite for each of the above.

Here's an example of scaffolding a resource called Task with a string name and a text description:

rails generate scaffold Task name:string description:text

This will generate the following files:

Controller: app/controllers/tasks_controller.rb
Test:       test/models/task_test.rb
            test/controllers/tasks_controller_test.rb
Routes:     resources :tasks added in routes.rb
Views:      app/views/tasks
            app/views/tasks/index.html.erb
            app/views/tasks/edit.html.erb
            app/views/tasks/show.html.erb
            app/views/tasks/new.html.erb
            app/views/tasks/_form.html.erb
Helper:     app/helpers/tasks_helper.rb
JS:         app/assets/javascripts/tasks.coffee 
CSS:        app/assets/stylesheets/tasks.scss
            app/assets/stylesheets/scaffolds.scss

example to delete files generated by scaffold for the resource called Task

rails destroy scaffold Task