jeudi 10 août 2017

after_destroy display unscoped value with observer class in rails

I am trying to add to the activity canceled value with after_destoy in observer class, but no value come through to display. if the booking is deleted, the booking flagged as canceled. Any idea how to add the canceled value to the activity with after_destroy?

Many thanks.

This is my observer class:

 class BookingObserver < ActiveRecord::Observer
  def after_destroy(booking)
     Activity.add(booking.venue, booking.created_by, 
     Activity::BOOKING_CANCELLED, booking) unless booking.imported?
  end
  def after_create(booking)

   Activity.add(booking.venue, booking.created_by, 
   Activity::BOOKING_CREATED, booking) unless booking.imported?
  end
 def after_update(booking)
  Activity.add(booking.venue, booking.created_by, 
  Activity::BOOKING_UPDATED, booking) unless booking.imported?
 end
end

Aucun commentaire:

Enregistrer un commentaire