When I look for a database, let's say fruits
, I can use Fruit.where("name" => "Lime")
(or similar) to pull up my Fruitopedia article on the Lime. Let's say I use some code like Cactus.where("breed" => "Saguaro")
. Would that mean my database is cacti
? Cactipedia doesn't want their database to be called cactuss
. It would make them look like they had no idea how to pluralize cactus. If so, what are my options about fixing this?
Asked
Active
Viewed 65 times
-1
-
Please read Rails guides and something about databases (MySQL for example has good docs) until you understand what: database, table, column, and relation means. This question makes no sense now. – Mike Szyndel Dec 20 '13 at 08:13
2 Answers
1
If your model name is "Cactus", Rails typically has some very good helper models that will automatically create the right plural form in your tables.
In the case that it doesn't turn "cactus" into "cacti", you can customize the inflection yourself. Check out "How do I override rails naming conventions?".

Community
- 1
- 1

biodynamiccoffee
- 518
- 7
- 12
-
Thanks, and luckily it isn't named cactus and Cactipedia/Fruitopedia do not exist (and hopefully never will) – Algo Dec 20 '13 at 05:16
0
You can name your table whatever you want. Just set the table name in your model:
class Something < ActiveRecord::Base
self.table_name = "something_else"
end
Rails will automatically derive the table name from the model name if the table_name
is not explicitly set.

the Tin Man
- 158,662
- 42
- 215
- 303

usha
- 28,973
- 5
- 72
- 93