# Simple scaffold question

**URL:** <https://www.ruby-forum.com/t/simple-scaffold-question/82288>\
**Category:** Rails\
**Created:** [December 30, 2005, 3:47am UTC](https://www.ruby-forum.com/t/simple-scaffold-question/82288 "2005-12-30T03:47:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![McClain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/3e96dc/32.png) [@McClain](https://www.ruby-forum.com/u/McClain)\
**Post date:** [December 30, 2005, 3:47am UTC](https://www.ruby-forum.com/t/simple-scaffold-question/82288/1 "2005-12-30T03:47:52Z")

</div>

How do I get scaffold to generate code for a table whos name is not  
plural  
of the modelname I give to it. I.E., If I have an existing database, and  
wish to generate scaffold code for existing tables, is this possible???

---

<div class="post-metadata">

**Author:** ![McClain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/3e96dc/32.png) [@McClain](https://www.ruby-forum.com/u/McClain)\
**Post date:** [December 30, 2005, 8:03am UTC](https://www.ruby-forum.com/t/simple-scaffold-question/82288/2 "2005-12-30T08:03:55Z")

</div>

In the model class do

set\_table\_name “MyTable”

---

<div class="post-metadata">

**Author:** ![McClain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/3e96dc/32.png) [@McClain](https://www.ruby-forum.com/u/McClain)\
**Post date:** [December 30, 2005, 3:17pm UTC](https://www.ruby-forum.com/t/simple-scaffold-question/82288/3 "2005-12-30T15:17:03Z")

</div>

McClain wrote:

> How do I get scaffold to generate code for a table whos name is not  
> plural  
> of the modelname I give to it. I.E., If I have an existing database, and  
> wish to generate scaffold code for existing tables, is this possible???

“ruby script/generate scaffold model model”

This circumvents the auto pluralization in the scaffold generator.

---

<div class="post-metadata">

**Author:** ![McClain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/3e96dc/32.png) [@McClain](https://www.ruby-forum.com/u/McClain)\
**Post date:** [January 20, 2006, 1:48am UTC](https://www.ruby-forum.com/t/simple-scaffold-question/82288/4 "2006-01-20T01:48:55Z")

</div>

McClain wrote:

> How do I get scaffold to generate code for a table whos name is not  
> plural  
> of the modelname I give to it. I.E., If I have an existing database, and  
> wish to generate scaffold code for existing tables, is this possible???

Edit the ./config/environment.rb file in your application’s directory.  
Down the bottom there is a commented-out section showing various ways to  
set the plurals of words. This is perfect for eg. setting the plural of  
“staff” to “staff” but might have other side-effects in your app other  
than just getting the table name to work. If you don’t want to do this  
then renaming the table to what ruby wants it to be (eg. rename  
‘tblStaff’ to ‘staffs’), run the scaffold, rename the table back, then  
add ‘set\_table\_name “tblStaff”’ to the model class.
