Scaffolding in Ruby on Rails

Let's scaffold a User entity:

 $ rails generate scaffold User name:string email:string
      invoke  active_record
      create    db/migrate/20140321214418_create_users.rb
      create    app/models/user.rb
      invoke    test_unit
      create      test/models/user_test.rb
      create      test/fixtures/users.yml
      invoke  resource_route
       route    resources :users
      invoke  scaffold_controller
      create    app/controllers/users_controller.rb
      invoke    erb
      create      app/views/users
      create      app/views/users/index.html.erb
      create      app/views/users/edit.html.erb
      create      app/views/users/show.html.erb
      create      app/views/users/new.html.erb
      create      app/views/users/_form.html.erb
      invoke    test_unit
      create      test/controllers/users_controller_test.rb
      invoke    helper
      create      app/helpers/users_helper.rb
      invoke      test_unit
      create        test/helpers/users_helper_test.rb
      invoke    jbuilder
      create      app/views/users/index.json.jbuilder
      create      app/views/users/show.json.jbuilder
      invoke  assets
      invoke    coffee
      create      app/assets/javascripts/users.js.coffee
      invoke    scss
      create      app/assets/stylesheets/users.css.scss
      invoke  scss
      create    app/assets/stylesheets/scaffolds.css.scss

Migrate: Create database table and columns

bundle exec rake db:migrate
==  CreateUsers: migrating ====================================================
-- create_table(:users)
   -> 0.1291s
==  CreateUsers: migrated (0.1292s) ===========================================

Migrate: Update table with a new column

$ rails generate migration add_password_digest_to_users password_digest:string
invoke  active_record
      create    db/migrate/20140321215104_add_password_digest_to_users.rb

This creates a migration file in the /db/migration folder with the content

class AddPasswordDigestToUsers < ActiveRecord::Migration
  def change
    add_column :users, :password_digest, :string
  end
end

We then run bundle exec rake db:migrate to update the database

$ bundle exec rake db:migrate
==  AddPasswordDigestToUsers: migrating =======================================
-- add_column(:users, :password_digest, :string)
   -> 0.2468s
==  AddPasswordDigestToUsers: migrated (0.2468s) ==============================

If you're in development mode, you would get an error message when you browse to /users:

ActiveRecord::PendingMigrationError
Migrations are pending; run 'bin/rake db:migrate RAILS_ENV=development' to resolve this issue.