Old Scaffold Problem on Lynda Ruby on Rails Essential Training

There are a number of people following lynda.com’s Ruby on Rails Essential Training tutorial and running into issues since some of the information in the tutorial is outdated. The method scaffold was removed from Rails 2.0. You can still create scaffolds but must do so by generating the scaffold files explicitly.

Processing ApplicationController#index (for ::1 at 2010-01-11 21:04:25) [GET]

NoMethodError (undefined method `scaffold' for AdminController:Class):
  app/controllers/admin_controller.rb:2
  /usr/local/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
  /usr/local/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
  /usr/local/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
  /usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start'
  /usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
  /usr/local/lib/ruby/1.8/webrick/server.rb:95:in `start'
  /usr/local/lib/ruby/1.8/webrick/server.rb:92:in `each'
  /usr/local/lib/ruby/1.8/webrick/server.rb:92:in `start'
  /usr/local/lib/ruby/1.8/webrick/server.rb:23:in `start'
  /usr/local/lib/ruby/1.8/webrick/server.rb:82:in `start'

Assuming you are following the Ruby on Rails Essential Training video Ch. 5. Setting up a Database | Scaffold: Magic CRUD Screencast, you can get some clues as to what Table and fields needs to be created with the script/generate command. Notice below the db/schema.rb file contains the following table albums and fields title, artist, release_date and genre. Also notice their corresponding field types.

ActiveRecord::Schema.define(:version => 0) do

  create_table "albums", :force => true do |t|
    t.string   "title",                      :null => false
    t.string   "artist",                     :null => false
    t.datetime "release_date",               :null => false
    t.string   "genre",        :limit => 50, :null => false
  end

end

Execute the following command:

script/generate scaffold Album title:string artist:string release_date:datetime genre:string

Then restart your server and hit http://localhost:3000/albums instead of http://localhost:3000:/admin

VN:F [1.9.22_1171]
Rating: 4.7/5 (7 votes cast)
VN:F [1.9.22_1171]
Rating: +5 (from 7 votes)
Old Scaffold Problem on Lynda Ruby on Rails Essential Training, 4.7 out of 5 based on 7 ratings
Facebook Twitter Email

2 Comments to “Old Scaffold Problem on Lynda Ruby on Rails Essential Training”