Rails 3.1 - has_and_belongs_to_many 已弃用? [英] Rails 3.1 - has_and_belongs_to_many deprecated?

查看:40
本文介绍了Rails 3.1 - has_and_belongs_to_many 已弃用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个当前为 Rails 3.0.9 的应用程序,具有非常简单的多对多关系:

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

我收到以下警告:

弃用警告:在 has_and_belongs_to_many 关联的连接表上具有附加属性已弃用,并将在 Rails 3.1 中删除.请改用 has_many :through 关联.

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);

has_and_belongs_to_many 是否在 Rails 3.1 中完全弃用了?我尝试升级到 3.1,但我使用了一些尚未更新的 gem,所以我要等一段时间,但理想情况下,我希望我的代码部分能够正常运行.

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.

推荐答案

它已被弃用,但仍然存在.它不会检查来查看连接表上是否有属性,它只是让您知道.它仍然有效.

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.

这篇关于Rails 3.1 - has_and_belongs_to_many 已弃用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆