ruby-on-railsassociationshas-and-belongs-to-many

for has_and_belongs_to_many table name should be in singular or plural


for has_many we will use plural definitely for belongs_to we will use singular for ex: has_many :users belongs_to: user

But for has_and_belongs_to_many has_and_belongs_to_many :user, join_table: :blocked_contacts here it should be user or users


Solution

  • It should be has_and_belongs_to_many :users, because it is a many-to-many relationship. You can find more info here.