Rails ActiveRecord 3.2: How to skip before_delete callback in child model?
问题 I'm working in Rails 3.2.16. In my app, an account has_many users. An account must always have admin users, so you can't destroy them. This takes care of that: class Account < ActiveRecord::Base has_many :users, :dependent => :destroy end class User < ActiveRecord::Base before_destroy :check_if_admin def check_if_admin false if self.is_admin end end However, when you destroy the whole account, the admins should be destroyed as well. Instead, when I call @account.destroy from the controller,