Scaffold error: try creating a table for your model

I decided to return to the tutorial at <http://developer.apple.com/
tools/rubyonrails.html> because I did once get the desired result,
namely a CRUD interface for a table. I slavishly followed the
tutorial but now get an error when running the scaffold command.

I’m frustrated that I’m missing a step somewhere, particularly because
I once did get it working. This time I kept a record of what I did.
I’d like to, and need to be able to, reliably get things started.

Here’s the record of what I was doing, if you spot what I did wrong
pls do let me know. I’m just curious why the rake command didn’t
create a table:

thufir@arrakis ~/rubyCode $
thufir@arrakis ~/rubyCode $
thufir@arrakis ~/rubyCode $
thufir@arrakis ~/rubyCode $ cat expenses.txt
Script started on Tue Nov 27 20:46:28 2007
thufir@arrakis ~/rubyCode $
thufir@arrakis ~/rubyCode $ mysql --user=root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.44-log Gentoo Linux mysql-5.0.44

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql> show databases;
±-------------------+
| Database |
±-------------------+
| information_schema |
| feed_on_feeds |
| mysql |
| straw_development |
| test |
±-------------------+
5 rows in set (0.10 sec)

mysql> create database expenses_development;
Query OK, 1 row affected (0.06 sec)

mysql> show databases;
±---------------------+
| Database |
±---------------------+
| information_schema |
| expenses_development |
| feed_on_feeds |
| mysql |
| straw_development |
| test |
±---------------------+
6 rows in set (0.00 sec)

mysql> show tables from expenses_development;
Empty set (0.00 sec)

mysql> quit
Bye
thufir@arrakis ~/rubyCode $
thufir@arrakis ~/rubyCode $ rm -rf expenses
thufir@arrakis ~/rubyCode $
thufir@arrakis ~/rubyCode $ rails expenses
create
create app/controllers
create app/helpers
create app/models
create app/views/layouts
create config/environments
create components
create db
create doc
create lib
create lib/tasks
create log
create public/images
create public/javascripts
create public/stylesheets
create script/performance
create script/process
create test/fixtures
create test/functional
create test/integration
create test/mocks/development
create test/mocks/test
create test/unit
create vendor
create vendor/plugins
create tmp/sessions
create tmp/sockets
create tmp/cache
create tmp/pids
create Rakefile
create README
create app/controllers/application.rb
create app/helpers/application_helper.rb
create test/test_helper.rb
create config/database.yml
create config/routes.rb
create public/.htaccess
create config/boot.rb
create config/environment.rb
create config/environments/production.rb
create config/environments/development.rb
create config/environments/test.rb
create script/about
create script/breakpointer
create script/console
create script/destroy
create script/generate
create script/performance/benchmarker
create script/performance/profiler
create script/process/reaper
create script/process/spawner
create script/process/inspector
create script/runner
create script/server
create script/plugin
create public/dispatch.rb
create public/dispatch.cgi
create public/dispatch.fcgi
create public/404.html
create public/500.html
create public/index.html
create public/favicon.ico
create public/robots.txt
create public/images/rails.png
create public/javascripts/prototype.js
create public/javascripts/effects.js
create public/javascripts/dragdrop.js
create public/javascripts/controls.js
create public/javascripts/application.js
create doc/README_FOR_APP
create log/server.log
create log/production.log
create log/development.log
create log/test.log
thufir@arrakis ~/rubyCode $
thufir@arrakis ~/rubyCode $
thufir@arrakis ~/rubyCode $ cd expenses
thufir@arrakis ~/rubyCode/expenses $
thufir@arrakis ~/rubyCode/expenses $ script/server
=> Booting WEBrick…
=> Rails application started on http://0.0.0.0:3000
=> Ctrl-C to shutdown server; call with --help for options
[2007-11-27 20:48:23] INFO WEBrick 1.3.1
[2007-11-27 20:48:23] INFO ruby 1.8.6 (2007-09-24) [i686-linux]
[2007-11-27 20:48:23] INFO WEBrick::HTTPServer#start: pid=7997
port=3000
127.0.0.1 - - [27/Nov/2007:20:48:27 PST] “GET / HTTP/1.1” 200 7552

  • → /
    127.0.0.1 - - [27/Nov/2007:20:48:27 PST] “GET /javascripts/
    prototype.js HTTP/1.1” 200 71260
    http://0.0.0.0:3000/ → /javascripts/prototype.js
    127.0.0.1 - - [27/Nov/2007:20:48:28 PST] “GET /javascripts/effects.js
    HTTP/1.1” 200 38200
    http://0.0.0.0:3000/ → /javascripts/effects.js
    127.0.0.1 - - [27/Nov/2007:20:48:28 PST] “GET /images/rails.png HTTP/
    1.1” 200 1787
    http://0.0.0.0:3000/ → /images/rails.png
    127.0.0.1 - - [27/Nov/2007:20:48:28 PST] “GET /favicon.ico HTTP/1.1”
    200 0
  • → /favicon.ico
    [2007-11-27 20:48:33] INFO going to shutdown …
    [2007-11-27 20:48:33] INFO WEBrick::HTTPServer#start done.
    thufir@arrakis ~/rubyCode/expenses $
    thufir@arrakis ~/rubyCode/expenses $ nano config/database.yml
    thufir@arrakis ~/rubyCode/expenses $
    thufir@arrakis ~/rubyCode/expenses $ cat config/database.yml
    development:
    adapter: mysql
    database: straw_development
    username: root
    password:
    host: localhost
    socket: /var/run/mysqld/mysqld.sock
    test:
    adapter: mysql
    database: straw_test
    username: root
    password:
    host: localhost
    socket: /var/run/mysqld/mysqld.sock
    production:
    adapter: mysql
    database: straw_production
    username: root
    password:
    host: localhost
    socket: /var/run/mysqld/mysqld.sock

thufir@arrakis ~/rubyCode/expenses $
thufir@arrakis ~/rubyCode/expenses
$
thufir@arrakis ~/rubyCode/expenses $
thufir@arrakis ~/rubyCode/expenses $ script/generate migration
accounts
create db/migrate
create db/migrate/001_accounts.rb
thufir@arrakis ~/rubyCode/expenses $
thufir@arrakis ~/rubyCode/expenses $
thufir@arrakis ~/rubyCode/expenses $ nano db/migrate/001_accounts.rb
thufir@arrakis ~/rubyCode/expenses $
thufir@arrakis ~/rubyCode/expenses $ cat db/migrate/001_accounts.rb
class Accounts < ActiveRecord::Migration

def self.up
create_table :accounts do |table|
table.column :name, :string
table.column :budget, :float
end
end

def self.down
drop_table :accounts
end
end
thufir@arrakis ~/rubyCode/expenses $
thufir@arrakis ~/rubyCode/expenses $ rake db:migrate
(in /home/thufir/rubyCode/expenses)
thufir@arrakis ~/rubyCode/expenses $
thufir@arrakis ~/rubyCode/expenses $ script/generate scaffold account
expenses
exists app/controllers/
exists app/helpers/
create app/views/expenses
exists app/views/layouts/
exists test/functional/
dependency model
exists app/models/
exists test/unit/
exists test/fixtures/
create app/models/account.rb
create test/unit/account_test.rb
create test/fixtures/accounts.yml
error Before updating scaffolding from new DB schema, try
creating a table for your model (Account) named accounts.
thufir@arrakis ~/rubyCode/expenses $
thufir@arrakis ~/rubyCode/expenses $ mysql --user=root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.0.44-log Gentoo Linux mysql-5.0.44

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql> show databases;
±---------------------+
| Database |
±---------------------+
| information_schema |
| expenses_development |
| feed_on_feeds |
| mysql |
| straw_development |
| test |
±---------------------+
6 rows in set (0.01 sec)

mysql>
mysql> show tables from expenses_development;
Empty set (0.00 sec)

mysql> quit
Bye
thufir@arrakis ~/rubyCode/expenses $ exit
exit

Script done on Tue Nov 27 21:02:06 2007
thufir@arrakis ~/rubyCode $

thanks,

Thufir