I am trying to replace my old database trigger with ActiveRecord
callbacks in rails.
I have a model like following:
class Action < ActiveRecord::Base
#clean up all action associated with the inquiry.
Action.update_all(“latest = ‘’”, [“inquiry_id = ?”,
#find the latest action
latest_action = Action.find(:first, :conditions => [“deleted <> 1
and inquiry_id = ?”, self.inquiry_id], :order => “action_date DESC, id
#mark ‘Y’ to the latest action.
latest_action.update_attribute(“latest”, “Y”) if latest_action
Model “Inquiry” has many “actions”, so I want to maintain the field
called “latest” to indicate the latest action.
However, this will not work. My after_update call another update, and
after_update is recursively called. This will end up with getting
Are there any way to temporary disable after_update callbacks?