Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
428 views
in Technique[技术] by (71.8m points)

ruby - Rails 3.1 - has_and_belongs_to_many deprecated?

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...