New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Delete all on has many relationship #9961
Comments
+1 |
@maletor Please create a gist with failing test as mentioned in section 1.2 http://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#create-a-self-contained-gist-for-active-record-issues |
i think you have a nested association there has_many :notifications, as: :subject, dependent: :delete_all
has_many :thread_subscriptions, through: :notifications, dependent: :delete_all according to the docs:
|
@maletor what is the state of this issue? Can you please provide an executable test-case as @neerajdotname suggested. This will help us to debug the problem. |
Not an issue. Should be closed https://gist.github.com/nishantmodak/8147200 - Gist Test Case for the issue. / @neerajdotname @maletor If one ends up using delete instead of destroy then its not going to work, as 'delete' would not look at the associations. |
It's been several months with no feedback. I'm giving this a close. Thanks @nishantmodak for the notification. 💛 |
My assumption is that I should be able to delete all ThreadSubscriptions when I delete an Alert, but instead an exception is raised "ActiveRecord::HasManyThroughCantAssociateThroughHasOneOrManyReflection: Cannot modify association 'Alert#thread_subscriptions' because the source reflection class 'ThreadSubscription' is associated to 'Notification' via :has_many."
If I am able to SELECT from the association what exactly is preventing me to DELETE from them?
https://gist.github.com/maletor/5259494#file-alert-rb-L23
The text was updated successfully, but these errors were encountered: