This project is archived and is in readonly mode.

#2688 ✓invalid
Olly Headey

ActiveRecord::HasManyThroughCantAssociateThroughHasManyReflection being thrown when calling destroy_all on a :has_many :through association

Reported by Olly Headey | May 21st, 2009 @ 01:04 PM | in 2.x

As of this commit, calling destroy_all on a :has_many :through association raises an ActiveRecord::HasManyThroughCantAssociateThroughHasManyReflection exception. This wasn't the case before this commit.

e.g. Given:

class Company
  has_many :projects, :through => :contacts
end

Calling company.projects.destroy_all results in:

ActiveRecord::HasManyThroughCantAssociateThroughHasManyReflection: Cannot modify association 'MyClass#projects' because the source reflection class 'Project' is associated to 'Contact' via :has_many

Calling company.projects.all.destroy_all works, however.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages