Activerecord 无法修改关联,因为源反射类通过以下方式关联:has\u many

Activerecord 无法修改关联,因为源反射类通过以下方式关联:has\u many,activerecord,ruby-on-rails-3.2,ruby-on-rails-2,Activerecord,Ruby On Rails 3.2,Ruby On Rails 2,我在Rails 2项目中的关联如下: class Role < ActiveRecord::Base belongs_to :user has_many :attrs, :through => :user, :dependent => :destroy end class User < ActiveRecord::Base has_many :roles, :order => 'id DESC', :dependent => :destroy

我在Rails 2项目中的关联如下:

class Role < ActiveRecord::Base
  belongs_to :user
  has_many :attrs, :through => :user, :dependent => :destroy
end

class User < ActiveRecord::Base
  has_many :roles, :order => 'id DESC', :dependent => :destroy
  has_many :attr, :dependent => :destroy
end

class Attr < ActiveRecord::Base
  belongs_to :user
  has_many :roles, :through => :user
end
类角色:user,:依赖=>:destroy
结束
类用户'id DESC',:依赖=>:destroy
有多个:attr,:dependent=>:destroy
结束
类Attr:用户
结束
我正在将我的项目升级到rails 3。在尝试删除rails 3中的用户时,出现以下错误:

无法修改关联“Role#attrs”,因为源反射类“Attr”通过以下方式与“User”关联:has#many

但出于同样的原因,在rails 2中,用户可以很好地被删除。我从来没有在rails 2上工作过,所以我不得不在这里问一下

我能做些什么来解决这个问题?我检查了其他答案,但它们似乎不适用于我的情况

在用户模型中 有多个:attr,:dependent=>:destroy

应该是 有多个:属性,:依赖=>:销毁