Rails naming convention for join table

Yogzzz picture Yogzzz · Jul 21, 2012 · Viewed 28.6k times · Source

This questions stems from: How to link form after creating rails join table

I am creating the join table between my Product and Category Models.

What should the join table be named? categories_products or category_products or something else?

Answer

Zabba picture Zabba · Jul 21, 2012

categories_products. Both plural. In lexical order.

Quote:

Unless the name of the join table is explicitly specified by using the :join_table option, Active Record creates the name by using the lexical order of the class names. So a join between customer and order models will give the default join table name of “customers_orders” because “c” outranks “o” in lexical ordering.