I am getting an error when I try to run the code for the depot
application (page 67 in the Agile Web D. on Rails book, 2nd
edition). I built the complete depot app with Rails 1.2.6, and all
worked well. I then updated to Gem 1.0.1 and RoR 2.0.2, and attempted
to repeat the tutorial, and got this strange behavior.
I used “rails depot --database=mysql” because I have not installed
sqlite3
I followed the instructions on pages 59 through 67 carefully, and
checked that the products table was created correctly.
I then added the scaffold line in admin_controller.rb (see below)
admin_controller.rb (code from example)
class AdminController < ApplicationController
scaffold :product
end
and then, started WEBrick, went to the browser and typed “http://
localhost:3000/admin/” and got the following dump in the browser
window.
NoMethodError in AdminController#index
==> undefined method `scaffold’ for AdminController:Class <==
RAILS_ROOT: /home/kenb/2nd-ed-rails-book/projects/depot
Application Trace | Framework Trace | Full Trace
app/controllers/admin_controller.rb:2
/usr/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/
dependencies.rb:203:in load_without_new_constant_marking' /usr/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/ dependencies.rb:203:in
load_file’
/usr/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/
dependencies.rb:342:in new_constants_in' /usr/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/ dependencies.rb:202:in
load_file’
/usr/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/
dependencies.rb:94:in require_or_load' /usr/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/ dependencies.rb:248:in
load_missing_constant’
/usr/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/
dependencies.rb:453:in const_missing' /usr/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/ dependencies.rb:465:in
const_missing’
/usr/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/
inflector.rb:257:in constantize' /usr/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/ core_ext/string/inflections.rb:148:in
constantize’
/usr/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
routing.rb:1426:in recognize' /usr/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/ dispatcher.rb:170:in
handle_request’
/usr/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
dispatcher.rb:115:in dispatch' /usr/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/ dispatcher.rb:126:in
dispatch_cgi’
/usr/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
dispatcher.rb:9:in dispatch' /usr/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb:112:in
handle_dispatch’
/usr/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb:78:in
service' /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in
service’
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in run' /usr/lib/ruby/1.8/webrick/server.rb:173:in
start_thread’
/usr/lib/ruby/1.8/webrick/server.rb:162:in start' /usr/lib/ruby/1.8/webrick/server.rb:162:in
start_thread’
/usr/lib/ruby/1.8/webrick/server.rb:95:in start' /usr/lib/ruby/1.8/webrick/server.rb:92:in
each’
/usr/lib/ruby/1.8/webrick/server.rb:92:in start' /usr/lib/ruby/1.8/webrick/server.rb:23:in
start’
/usr/lib/ruby/1.8/webrick/server.rb:82:in start' /usr/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb:62:in
dispatch’
/usr/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/servers/
webrick.rb:66
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in
gem_original_require' /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in
require’
/usr/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/
dependencies.rb:496:in require' /usr/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/ dependencies.rb:342:in
new_constants_in’
/usr/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/
dependencies.rb:496:in require' /usr/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/server.rb:39 /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in
gem_original_require’
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in
`require’
script/server:3
app/controllers/admin_controller.rb:2
/usr/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/
dependencies.rb:203:in load_without_new_constant_marking' /usr/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/ dependencies.rb:203:in
load_file’
/usr/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/
dependencies.rb:342:in new_constants_in' /usr/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/ dependencies.rb:202:in
load_file’
/usr/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/
dependencies.rb:94:in require_or_load' /usr/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/ dependencies.rb:248:in
load_missing_constant’
/usr/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/
dependencies.rb:453:in const_missing' /usr/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/ dependencies.rb:465:in
const_missing’
/usr/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/
inflector.rb:257:in constantize' /usr/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/ core_ext/string/inflections.rb:148:in
constantize’
/usr/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
routing.rb:1426:in recognize' /usr/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/ dispatcher.rb:170:in
handle_request’
/usr/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
dispatcher.rb:115:in dispatch' /usr/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/ dispatcher.rb:126:in
dispatch_cgi’
/usr/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
dispatcher.rb:9:in dispatch' /usr/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb:112:in
handle_dispatch’
/usr/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb:78:in
service' /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in
service’
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in run' /usr/lib/ruby/1.8/webrick/server.rb:173:in
start_thread’
/usr/lib/ruby/1.8/webrick/server.rb:162:in start' /usr/lib/ruby/1.8/webrick/server.rb:162:in
start_thread’
/usr/lib/ruby/1.8/webrick/server.rb:95:in start' /usr/lib/ruby/1.8/webrick/server.rb:92:in
each’
/usr/lib/ruby/1.8/webrick/server.rb:92:in start' /usr/lib/ruby/1.8/webrick/server.rb:23:in
start’
/usr/lib/ruby/1.8/webrick/server.rb:82:in start' /usr/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb:62:in
dispatch’
/usr/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/servers/
webrick.rb:66
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in
gem_original_require' /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in
require’
/usr/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/
dependencies.rb:496:in require' /usr/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/ dependencies.rb:342:in
new_constants_in’
/usr/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/
dependencies.rb:496:in require' /usr/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/server.rb:39 /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in
gem_original_require’
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in
`require’
script/server:3
Request
Parameters:
None
Show session dump
flash: !map:ActionController::Flash::FlashHash {}
Response
Headers:
{“cookie”=>[],
“Cache-Control”=>“no-cache”}