I would like to have an item automatically destroyed when a necessary 
association has been removed via a call to a `remove_association` method. 
 I have achieved this right now with an extra bit of markup that looks like 
this:

```ruby
class Group < Sequel::Model
  one_to_many :members, remover: ->(member) { member.destroy }`
end
```

this seems to work, and any `Member` instance is destroyed when I call 
`remove_member(member)` on a `Group` instance.  but I'm curious if this is 
an appropriate and best way of doing this.  It'd be great if there was an 
option/plugin that would do this automatically when the db schema migration 
specifies something like:

```ruby
create_table(:members) {
  foreign_key :group_id, :groups, null: false, on_delete: :cascade
}
```

thanks for any help and apologies if I've missed this in the documentation 
or am conceptually being stupid :) 

-- 
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 sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/90a84a04-3edf-41e8-873a-9cf4cae056fcn%40googlegroups.com.

Reply via email to