Forum: Ruby on Rails before_destroy return false, but dependent are destroyed

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
8166a9470863dc82b73f42c60c667f8a?d=identicon&s=25 Tomasz Bak (Guest)
on 2007-03-14 22:43
I have a problem with before_destroy deleting by dependent records,
even through I return flase.

  has_many :users,   :class_name => 'Editor', :as => :editable,
:dependent => :destroy

  def before_destroy
    unless self.has_access?(99)
      errors.add_to_base "Destroy permissions error!"
      return false

When I remove the dependent => :destroy and put users.destroy_all it
works ok.

I use rails 1.2.2. ruby 1.8.5, win32.

Best regards,
This topic is locked and can not be replied to.