Delete Cascade to include associated records?

Is it possible to delete records that have an association (foreign key) to schedule_elements in a single call? Do I just combine the associated relation?

schedule_elements.where(conditions).command(:delete, result: :many).call

P.S. Can “command(:delete, result: :many)” just return ids?


I may have answered my own question using sequel, however, are there any tricks in ROM to do this?

Foreign Key Options


    Specify the behavior of this foreign key column when the row with the primary key it references is deleted, can be :restrict, :cascade, :set_null, or :set_default. You can also use a string, which is used literally.

It’s best to define an FK constraint at the database level with on_delete: :cascade