Rails 3.1 - has_and_belongs_to_many deprecated?

2020-02-07 03:28发布

I've got an application currently Rails 3.0.9, with a very simple many to many relationship:

class User < ActiveRecord::Base
  has_and_belongs_to_many :stores, :join_table => "users_stores"
end

I'm getting the following warning popping up all over the place:

DEPRECATION WARNING: Having additional attributes on the join table of a has_and_belongs_to_many association is deprecated and will be removed in Rails 3.1. Please use a has_many :through association instead.

The thing is, I don't have any extra attributes on the join table:

sqlite> .schema users_stores
CREATE TABLE "users_stores" ("user_id" integer, "store_id" integer);

Is has_and_belongs_to_many completely deprecated in Rails 3.1? I tried an upgrade to 3.1 but I'm using some gems which haven't yet been updated, so I'm waiting a while longer, but ideally, I'd like my part of the code to be good to go.

1条回答
Fickle 薄情
2楼-- · 2020-02-07 03:46

It's deprecated, but still there. It doesn't check to see if you have attributes on the join table, it's just letting you know. It still works.

查看更多
登录 后发表回答