Using external resources in callbacks in rails by releu

757fb0d5ec7560b6f25f5bd98eadc020?size=52

Here is a typical bad case in #rails:

class Band < ActiveRecord::Base
  has_many :members, dependent: :destroy
end

class Member < ActiveRecord::Base
  belongs_to :band

  after_destroy do
    Resque.enqueue BadNewsWorker, id
    raise('surprise') # real world :(
  end
end

band = Band.create
band.members.create
band.destroy # => RuntimeError
Band.count => 1

More under the cut