My associations in a Rails 2 project are as follows:
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
I am upgrading my project to rails 3. And while trying to delete user in rails 3, I get the following error:
Cannot modify association 'Role#attrs' because the source reflection class 'Attr' is associated to 'User' via :has_many.
But for the same thing, in rails 2 the users get deleted fine. I have never worked on rails 2 so I had to ask here.
What Can I do to fix this? I checked other answers but they don't seem to apply to my case.