Scaffold a Plural table w/ No Pluralization in environment

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

script/generate scaffold my_tables table

it seems to work out fine for certain sections like (which also inserts properly to my
database). But when I go to, I get an
application error. My logs are:

Processing SpielController#list (for 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?



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.



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 :slight_smile:


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs