对于 has_and_belongs_to_many 表名应该是单数或复数

问题描述 投票:0回答:1

对于

has_many
我们肯定会使用复数 对于
belongs_to
我们将使用单数 例如:
has_many :users
belongs_to: user

但是为了

has_and_belongs_to_many
has_and_belongs_to_many :user, join_table: :blocked_contacts
这里应该是
user
users

ruby-on-rails associations has-and-belongs-to-many
1个回答
1
投票

应该是

has_and_belongs_to_many :users
,因为是多对多的关系。您可以在此处找到更多信息。

© www.soinside.com 2019 - 2024. All rights reserved.