Displaying 1 result from an estimated 1 matches for "destroyrestricted".
2006 Aug 06
0
Rails Core Weekly July 16 - August 6
...method to leapfrog the callback chain."
associations.rb, configure_dependency_*
case reflection.options[:dependent]
when :restrict
class_eval <<-end_eval
def destroy_with_has_many_#{reflection.name}
unless #{reflection.name}.blank?
raise DestroyRestricted.new(self, #{reflection.name.inspect})
end
end
alias_method_chain :destroy, "has_many_#{reflection.name}"
end_eval
# ...
end
base.rb
module ActiveRecord
class DestroyRestricted < ActiveRecordError
def initialize(model, by)...