On Monday, April 8, 2019 at 1:52:20 PM UTC-7, Chris Elsworth wrote: > > Hi Jeremy, > > The problem is the soft deletion needs to happen in the many_to_many join > table. I'm not sure if I can get access to that table in the before_destroy > method? > > Just to make this clear, what I currently have is: > > class Artist > many_to_many :tracks, join_table: :albums > plugin :association_dependencies, tracks: :nullify > end > > So here when I delete an artist, their albums are removed from the join > table but the tracks are left behind. What I need to achieve is the album > rows are updated with deleted_at instead. I think the before_destroy method > above will set deleted_at in the tracks table? Which isn't quite right. > > I'm not entirely sure what a solution might look like, I'm kind of fishing > for ideas on how to make this work at the moment.. >
In this case, association_dependencies will call the remove all method for the association, so you can use a custom association :remover option to implement it. I still think the trigger-based approach is better for this. Thanks, Jeremy -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/sequel-talk. For more options, visit https://groups.google.com/d/optout.
