i have two different after_create callbacks. I only want one to run when a field is present in the created record
i have an idea of how to do it but i can’t quite get the syntax
#rental.rb
after_create :delete_booking , :if => ":booking_no = 'NOT NULL'"
after_create :set_requires_allocation
def delete_booking
@booking = Booking.where(:booking_no => self.booking_no).first
@booking.destroy
end
def set_requires_allocation
self.user.requires_allocation = 'false'
end
also will set_requires_allocation actually acheive what i think it will by changing ‘true’ to ‘false’ in the users table?
thanks
1 Answer