# The dreaded "Before updating scaffolding" error

**URL:** <https://www.ruby-forum.com/t/the-dreaded-before-updating-scaffolding-error/85484>\
**Category:** Rails\
**Created:** [February 13, 2007, 11:50pm UTC](https://www.ruby-forum.com/t/the-dreaded-before-updating-scaffolding-error/85484 "2007-02-13T23:50:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jay\_Mottern](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/73ab20/32.png) [@Jay\_Mottern](https://www.ruby-forum.com/u/Jay_Mottern)\
**Post date:** [February 13, 2007, 11:50pm UTC](https://www.ruby-forum.com/t/the-dreaded-before-updating-scaffolding-error/85484/1 "2007-02-13T23:50:07Z")

</div>

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 [Radar – O’Reilly](http://www.onlamp.com/pub/a/onlamp/2006/12/14/revisiting-)  
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)

F:\InstantRails\rails\_apps\pidb1\_development\>

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)  
references  
caseinfo(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)  
references  
caseinfo(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)  
references  
caseinfo(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)  
references  
caseinfo(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)  
references  
caseinfo(id),  
primary key(id)  
) engine=InnoDB;  
create table evidence (  
id int not null  
auto\_increment,  
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)  
references  
caseinfo(id),  
primary key(id)  
) engine=InnoDB;  
create table summary (  
id int not null  
auto\_increment,  
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)  
references  
caseinfo(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?

Thanks.  
-Jay

---

<div class="post-metadata">

**Author:** ![Jay\_Mottern](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/73ab20/32.png) [@Jay\_Mottern](https://www.ruby-forum.com/u/Jay_Mottern)\
**Post date:** [February 14, 2007, 5:07pm UTC](https://www.ruby-forum.com/t/the-dreaded-before-updating-scaffolding-error/85484/2 "2007-02-14T17:07:53Z")

</div>

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?

-Jay

---

<div class="post-metadata">

**Author:** ![Jay\_Mottern](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/73ab20/32.png) [@Jay\_Mottern](https://www.ruby-forum.com/u/Jay_Mottern)\
**Post date:** [February 14, 2007, 9:47pm UTC](https://www.ruby-forum.com/t/the-dreaded-before-updating-scaffolding-error/85484/3 "2007-02-14T21:47:38Z")

</div>

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  
would  
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  
this  
off or manually map models to tables, but its usually best to go with  
the  
default conventions (let Rails do the work for you).

Curt

---

<div class="post-metadata">

**Author:** ![Jay\_Mottern](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/73ab20/32.png) [@Jay\_Mottern](https://www.ruby-forum.com/u/Jay_Mottern)\
**Post date:** [February 14, 2007, 11:00pm UTC](https://www.ruby-forum.com/t/the-dreaded-before-updating-scaffolding-error/85484/4 "2007-02-14T23:00:46Z")

</div>

And use Migrations to build your database instead of SQL if possible,
