Forum: Ruby on Rails The dreaded "Before updating scaffolding" error

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.
2ad3462e2aab26174f2258ca0ef3af71?d=identicon&s=25 Jay Mottern (Guest)
on 2007-02-13 23:50
(Received via mailing list)
I'm a newbie to web app development, MySQL, etc. and am giving Rails a
try via InstantRails 1.4 on a Windows XP SP2 platform.

I've created my database and tables etc. and, following the tutorial
located at
ruby-on-rails-revisited.html?page=1 I run the following command:

ruby script\generate scaffold caseinfo caseinfo

and I get:

F:\InstantRails\rails_apps\pidb1_development>ruby script\generate
scaffold casei
nfo caseinfo
      exists  app/controllers/
      exists  app/helpers/
      exists  app/views/caseinfo
      exists  test/functional/
  dependency  model
      exists    app/models/
      exists    test/unit/
      exists    test/fixtures/
   identical    app/models/caseinfo.rb
   identical    test/unit/caseinfo_test.rb
   identical    test/fixtures/caseinfos.yml
       error  Before updating scaffolding from new DB schema, try
creating a tab
le for your model (Caseinfo)


I get the same error when trying to generte the scaffolds for any
other existing table.

Here's the SQL script I wrote to generate the tables and fields. It
runs OK, everything's there, and I can connect to the database as root
from the command line:

drop table if exists initcontact;
drop table if exists followups;
drop table if exists interview;
drop table if exists research;
drop table if exists baselines;
drop table if exists evidence;
drop table if exists summary;
drop table if exists caseinfo;
create table caseinfo (
    id                     int            not null auto_increment,
    name                   varchar(100)   not null default '',
    description         text           null,
    primary key(id)
) engine=InnoDB;
create table initcontact (
       id                     int            not null auto_increment,
       initcontact_id         int            not null,
       sentfrom               varchar(100)   not null default '',
       date                   date           null,
       address                varchar(100)   not null default '',
       phone                  varchar(15)    not null default '',
       email                  varchar(100)   not null default '',
       details            mediumtext     null,
       replyfrom              varchar(100)   not null default '',
       replydate              date           null,
       replydetails           mediumtext     null,
       constraint fk_caseinfo_initcontact foreign key (initcontact_id)
       primary key(id)
) engine=InnoDB;
create table followups   (
     id                     int            not null auto_increment,
     followups_id           int            not null,
       fu1from                varchar(100)   not null default '',
       fu1date                date           null,
       fu1details             mediumtext     null,
       fu1replyfrom           varchar(100)   not null default '',
       fu1replydate           date           null,
       fu1replydetails        mediumtext     null,
       fu2from                varchar(100)   not null default '',
       fu2date                date           null,
       fu2details             mediumtext     null,
       fu2replyfrom           varchar(100)   not null default '',
       fu2replydate           date           null,
       fu2replydetails        mediumtext     null,
       fu3from                varchar(100)   not null default '',
       fu3date                date           null,
       fu3details             mediumtext     null,
       fu3replyfrom           varchar(100)   not null default '',
       fu3replydate           date           null,
       fu3replydetails        mediumtext     null,
       fu4from                varchar(100)   not null default '',
       fu4date                date           null,
       fu4details             mediumtext     null,
       fu4replyfrom           varchar(100)   not null default '',
       fu4replydate           date           null,
       fu4replydetails        mediumtext     null,
       fu5from                varchar(100)   not null default '',
       fu5date                date           null,
       fu5details             mediumtext     null,
       fu5replyfrom           varchar(100)   not null default '',
       fu5replydate           date           null,
       fu5replydetails        mediumtext     null,
       fu6from                varchar(100)   not null default '',
       fu6date                date           null,
       fu6details             mediumtext     null,
       fu6replyfrom           varchar(100)   not null default '',
       fu6replydate           date           null,
       fu6replydetails        mediumtext     null,
       constraint fk_caseinfo_followups foreign key (followups_id)
       primary key(id)
) engine=InnoDB;
create table interview   (
       id                     int            not null auto_increment,
       interview_id           int            not null,
       date                  date           null,
       starttime          time           null,
       conductedby            varchar(100)   not null default '',
       interviewees           mediumtext     null,
       location               text           null,
       sensitivity            text           null,
       priorbelief            varchar(100)   not null default '',
       priorexperiences       mediumtext     null,
       recentdeath            mediumtext     null,
       recenttrauma           mediumtext     null,
       occult                 mediumtext     null,
       religious              mediumtext     null,
       details                mediumtext     null,
       endtime                time           null,
       investigationwarranted varchar(100)   not null default '',
       constraint fk_caseinfo_interview foreign key (interview_id)
       primary key(id)
) engine=InnoDB;
create table research    (
       id                     int            not null auto_increment,
       research_id            int            not null,
       doneby                 varchar(100)   not null default '',
       siteaddress            text           null,
       areainfo               text           null,
       siteage                varchar(100)   not null default '',
       sitehistory            mediumtext     null,
       siteenvironment        mediumtext     null,
       sitecomments           mediumtext     null,
       constraint fk_caseinfo_research foreign key (research_id)
       primary key(id)
) engine=InnoDB;
create table baselines    (
       id                     int            not null auto_increment,
       baselines_id           int            not null,
       permission             varchar(10)    not null default '',
       date                   date           null,
       starttime              time           null,
       members                mediumtext     null,
       witnesses              mediumtext     null,
       pets                   mediumtext     null,
       weather                mediumtext     null,
       solar                  varchar(50)    not null default '',
       geomagnetic            varchar(50)    not null default '',
       moonphase              varchar(50)    not null default '',
       equipment              mediumtext     null,
       baseemf                mediumtext     null,
       basetemp               mediumtext     null,
       baseambient            mediumtext     null,
       baseother              mediumtext     null,
       constraint fk_caseinfo_baselines foreign key (baselines_id)
       primary key(id)
) engine=InnoDB;
create table evidence (
       id                            int           not null
       evidence_id                   int           not null,
       audiovisual                   mediumtext    null,
       phystactile                   mediumtext    null,
       photographic                  mediumtext    null,
       video                         mediumtext    null,
       emf                           mediumtext    null,
       tempanomalies                 mediumtext    null,
       elecanomalies                 mediumtext    null,
       evp                           mediumtext    null,
       psychicimpress                mediumtext    null,
       triggerused                   varchar(15)   not null default
       triggerdetails                mediumtext    null,
       triggermoved                  varchar(15)   not null default
       triggermoveddetail            mediumtext    null,
       otheranomalies                mediumtext    null,
       endtime                       time          null,
       comments                      mediumtext    null,
       constraint fk_caseinfo_evidence foreign key (evidence_id)
       primary key(id)
) engine=InnoDB;
create table summary (
       id                            int           not null
       summary_id                    int           not null,
       summary                       mediumtext    null,
       haunted                       varchar(25)   not null default
       followupinvest                varchar(50)   not null default
       comments                      mediumtext    null,
       constraint fk_caseinfo_summary foreign key (summary_id)
       primary key(id)
) engine=InnoDB;

I see that lots of others are getting this same error when trying to
generate scaffolds. Any ideas or suggestions?

2ad3462e2aab26174f2258ca0ef3af71?d=identicon&s=25 Jay Mottern (Guest)
on 2007-02-14 17:07
(Received via mailing list)
More info: per the development.log file Rails is trying to append an
"s" to the table name.

   [4;36;1mCaseinfo Columns (0.000000) [0m    [0;1mMysql::Error:
#42S02Table 'pidb1_development.caseinfos' doesn't exist: SHOW FIELDS
FROM caseinfos [0m

Why the heck is it doing that?

C475cffda1800fbc3f3af17bc10c220f?d=identicon&s=25 Curt Hibbs (Guest)
on 2007-02-14 21:47
(Received via mailing list)
That's one of the conventions that Rails uses: model class names are
singular and database table names are plural. So a model name of "Entry"
would corresponde to a database table named "entries". Other examples
be: Order/orders, person/people, country/countries, address, addresses.

You can see that Rails is smart about English pluralization. Most of the
time this convention makes the code read more naturally. You can turn
off or manually map models to tables, but its usually best to go with
default conventions (let Rails do the work for you).

6ef8cb7cd7cd58077f0b57e4fa49a969?d=identicon&s=25 Brian Hogan (Guest)
on 2007-02-14 23:00
(Received via mailing list)
And use Migrations to build your database instead of SQL if possible,
This topic is locked and can not be replied to.