Forum: Ruby on Rails Issue with scaffolding with rail 2.2 and mySQL

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Stephen M. (Guest)
on 2008-12-13 15:18
(Received via mailing list)
Hi guys,
I'm having problems when creating basic web applications using rails
2.2 and mySQL databases.
If I create the following table in a database named

    name VARCHAR(30) NOT NULL );

and then run the following ruby commands:

rails -d mysql moviecritic (creates all the necessary files without any

I then modify the config/database.yml to include the root password to
my database and run then ruby the following ruby command:

ruby script/generate scaffold Movie (creates usual files without error).

If i now view the db/migrate.create_movies.rb i see the following:
class CreateMovies < ActiveRecord::Migration
  def self.up
    create_table :movies do |t|


  def self.down
    drop_table :movies

It doesn't make a reference to the name column i created! This is
reflected when i navigate to localhost:3000/movies/new i only see a
Back link and a Create Button, i don't see a NAME FIELD INPUT.

Has anyone any ideas why this is happening?
Thanks in advance,
Frederick C. (Guest)
on 2008-12-13 15:22
(Received via mailing list)
On Dec 13, 11:11 am, "Stephen Morrison" <removed_email_address@domain.invalid>
>     create_table :movies do |t|
> It doesn't make a reference to the name column i created! This is
You've got things back to front. the migration generator does not look
at an existing table. It's expecting that it will be creating a new
The scaffolding stuff used to introspect the database but that died a
while back

These days what you should do is
- create your rails app
- create the database

ruby script/generate scaffold Movie name:string
This will create the migration, views and controller. The migration
will create a table with a name column called string and the views
will show that field.
then run
rake db:migrate

to run the migration (ie actually create the table).

Stephen M. (Guest)
on 2009-01-07 23:05
Thanks for the help! Much appreciated!
Redden96 (Guest)
on 2009-01-09 03:36
(Received via mailing list)
I think that's crap. The scaffold should create the table if it does
not exist but if the table already exists then inspect the table and
generate the appropriate stuff. What a pain in the ass.

On Dec 13 2008, 7:22 am, Frederick C. <removed_email_address@domain.invalid>
This topic is locked and can not be replied to.