sferik/rails_admin — Issue #979: A before_destroy callback that returns false is ignored
Author: benbruscella
Created: 2012-02-12 12:57:10+00:00
State: open

As an example, I have an Idea model that has a before_destroy callback to check for has_many objects before allowing the delete:

before_destroy :check_can_delete

def check_can_delete

unless votes.empty?
self.errors.add :base, "We can't delete this idea as it has votes associated with it"
return false
end

end

This works as expected in the app.

However, when I use rails_admin to delete an Idea with votes, rails admin reports it as successfully deleted but the before_destroy ensures that the record is not deleted.

It'd be great if rails_admin reported that the deletion has failed with the correct flash message.