From: David Heinemeier Hansson Date: 2004-09-27T23:52:55+09:00 Subject: Re: [Rails] #has_and_belongs_to_many problem Try this instead: class Permission < ActiveRecord::Base has_and_belongs_to_many :roles protected def before_destroy connection.delete( "DELETE * FROM permissions_roles WHERE permission_id = #{id}" ) end end Some times a little SQL is just what you need. Active Record doesn't look down upon you for doing that. Unlike many other frameworks. I'll get a :dependent => true option in at some point that'll do this automatically, though. Oh, and thanks for the praise! I'm glad you're having fun and are being productive. -- David Heinemeier Hansson, http://www.rubyonrails.org/ -- Web-application framework for Ruby http://www.instiki.org/ -- A No-Step-Three Wiki in Ruby http://www.basecamphq.com/ -- Web-based Project Management http://www.loudthinking.com/ -- Broadcasting Brain http://www.nextangle.com/ -- Development & Consulting Services