ruby-on-rails - Rails 连接表命名约定

标签 ruby-on-rails ruby-on-rails-3 ruby-on-rails-3.1 rails-migrations

此问题源于:How to link form after creating rails join table

我正在我的产品模型和类别模型之间创建联接表。

连接表应该命名为什么? categories_products 或category_products 还是其他?

最佳答案

类别_产品。均为复数。按词汇顺序排列。

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.

关于ruby-on-rails - Rails 连接表命名约定,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11590469/

相关文章:

ruby-on-rails - 如何为 apipie-rails gem 生成 header ?

ruby-on-rails - 如何在 Ruby on Rails 中为表单元素添加 onchange 监听器?

ruby - 在 UTF-8 中提取无效字节序列

ruby-on-rails-3.1 - 获取 best_in_place gem 与 Redcarpet markdown 配合

ruby-on-rails - 从现有模型/数据库设计安装

ruby-on-rails - RVM 不更改 Mac 上的 Ruby 版本

ruby-on-rails - ActiveRecord::Batches::find_each 线程安全吗?

sql - Ruby on Rails : Finding the sum of a column in a returned search query

regex - 如何验证一个号码不是免费的?

mysql - 从 Rails 范围获取第二行