Rails add "s" to end of table name with MySQL DB query

I’m trying to figure out why my database.yml file is adding the letter
“s” to the name of my table when doing a query.

I tried wiping out my config and starting from scratch using different
file names and table names but it does the exact same thing. For
instance, my table is named “info”, when I try to access info from a
web browser, I get a mysql db connection error that says there is no
table named “infos”.

Any idea why this is happening?

thanks

john

On Dec 20, 2006, at 02:45 , jackster wrote:

I’m trying to figure out why my database.yml file is adding the letter
“s” to the name of my table when doing a query.

I tried wiping out my config and starting from scratch using different
file names and table names but it does the exact same thing. For
instance, my table is named “info”, when I try to access info from a
web browser, I get a mysql db connection error that says there is no
table named “infos”.

Any idea why this is happening?

Yes, that’s what ActiveRecord does by default; pluralized table
names. You can modify this behaviour easily by adding this to your
config/environment.rb:

ActiveRecord::Base.pluralize_table_names = false


Jakob S. - http://mentalized.net

Hi Jackster,

By default, Rails assumes that a table name is the plural form of the
corresponding model name. That assumption can be overridden by
uncommenting the line “# ActiveRecord::Base.pluralize_table_names =
false” in your config/environment.rb file. If you just want to set an
exception for info but pluralize everything else, you can activate and
modify the inflect.uncountable statement which also is commented out in
that same file.

This behavior is described in considerable detail in chapter 14 of the
current Pickaxe book.

– Mike

jackster wrote:

I’m trying to figure out why my database.yml file is adding the letter
“s” to the name of my table when doing a query.

I tried wiping out my config and starting from scratch using different
file names and table names but it does the exact same thing. For
instance, my table is named “info”, when I try to access info from a
web browser, I get a mysql db connection error that says there is no
table named “infos”.

Any idea why this is happening?

thanks

john

I think is the way MVC handles the DataBase. Tables map to Classes and
by default Active Recird assumes that the name of a table is a plural
name of the parallel class.
For example Class Shark would become a table name of Sharks.

Hope it helps.