my take on cascading deletes via a plugin for sequel
DRY up my code.
No more explicit
before_destroy to delete the children of
Run the following if you haven't already:
$ gem sources -a http://gems.github.com
Install the gem(s):
$ sudo gem install -r sbfaulkner-sequel_cascading
require 'rubygems' require 'sequel' class Comment < Sequel::Model many_to_one :post end class Post < Sequel::Model one_to_many :comment, :order => :name # destroy any associated records too is :cascading, :destroy => :comments # or, if you want to null the foreign key instead, you could... # is :cascading, :nullify => :comments # or, if you want the destroy to fail, you would... # is :cascading, :restrict => :comments end
- added support for :nullify and :restrict options
- add :null and :deny support?
- publish in sequel www/pages/plugins
Author: S. Brent Faulkner firstname.lastname@example.org
License: Copyright © 2009 unwwwired.net, released under the MIT license