# Scaffold a Plural table w/ No Pluralization in environment

**URL:** <https://www.ruby-forum.com/t/scaffold-a-plural-table-w-no-pluralization-in-environment/98796>\
**Category:** Rails\
**Created:** [July 18, 2006, 8:02am UTC](https://www.ruby-forum.com/t/scaffold-a-plural-table-w-no-pluralization-in-environment/98796 "2006-07-18T08:02:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sombrero](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/94ad74/32.png) [@sombrero](https://www.ruby-forum.com/u/sombrero)\
**Post date:** [July 18, 2006, 8:02am UTC](https://www.ruby-forum.com/t/scaffold-a-plural-table-w-no-pluralization-in-environment/98796/1 "2006-07-18T08:02:41Z")

</div>

Hi guys,

I have a situation here. I have my project set to no pluralization due  
to legacy tables in environment.rb. Now, I have some new tables which  
I’m starting to pluralize. When I do a generate a scaffold to this new  
table:

script/generate scaffold my\_tables table

it seems to work out fine for certain sections like  
[http://mysite.com/railsapp/new](http://mysite.com/railsapp/new) (which also inserts properly to my  
database). But when I go to [http://mysite.com/railsapp/list](http://mysite.com/railsapp/list), I get an  
application error. My logs are:

Processing SpielController#list (for 210.5.98.178 at 2006-07-18  
13:56:58) [GET]  
Session ID: 0be4d205f811096a827b21209cdc1370  
Parameters: {“action”=\>“list”, “controller”=\>“table”}

ActiveRecord::StatementInvalid (PGError: ERROR: relation “my\_table”  
does not exist.

Well, my\_table really doesn’t exist because the table name is my\_tables.  
With pluralization not activated in my environment, how can I have rails  
see this table?

Thanks,

Bing

---

<div class="post-metadata">

**Author:** ![sombrero](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/94ad74/32.png) [@sombrero](https://www.ruby-forum.com/u/sombrero)\
**Post date:** [July 18, 2006, 9:43am UTC](https://www.ruby-forum.com/t/scaffold-a-plural-table-w-no-pluralization-in-environment/98796/2 "2006-07-18T09:43:52Z")

</div>

Hey guys,

I found the answer. Just go to your models and put the line:

set\_table\_name “my\_tables”

It will tell ruby to look at my\_tables for the particular model.

thanks,

Bing

---

<div class="post-metadata">

**Author:** ![sombrero](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/94ad74/32.png) [@sombrero](https://www.ruby-forum.com/u/sombrero)\
**Post date:** [July 18, 2006, 3:09pm UTC](https://www.ruby-forum.com/t/scaffold-a-plural-table-w-no-pluralization-in-environment/98796/3 "2006-07-18T15:09:12Z")

</div>

Bing T. wrote:

> I found the answer. Just go to your models and put the line:
> 
> set\_table\_name “my\_tables”

Great to hear you solved your problem.

Given that pluralisation is the default behaviour, and any new tables  
going forward will be pluralised, I’d suggest you switch pluralisation  
back on again, and move the set\_table\_name special casing to the legacy  
tables/models (thus marking them as legacy 🙂

Alan
