On Tuesday, September 26, 2017 at 5:10:36 PM UTC-7, Carlos Azuaje wrote: > > Good morning, I'm getting the following error > > SQLite3 :: ConstraintException: FOREIGN KEY constraint failed > > The error occurs when I try to delete a record from table 'A' that is > associated with a record of table 'B' through a relationship Many to Many. >
This is expected relational behavior if you aren't cascading deletes. You need to delete the entries in the join table related to the row being deleted from table A before deleting the row from table A. You should be able to use the association_dependencies plugin if you want a model-level solution that deletes associated rows in the join table before deleting the current row. But it's probably best to cascade deletes the in the database instead of trying to emulate it at the model layer. Note that cascading deletes in general, either in the database or the model layer, is a fairly sharp knife that should be used with caution. 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.
