method
add_touch_callbacks
v3.1.0 -
Show latest stable
- Class:
ActiveRecord::Associations::Builder::BelongsTo
add_touch_callbacks(reflection)private
No documentation available.
# File activerecord/lib/active_record/associations/builder/belongs_to.rb, line 46
def add_touch_callbacks(reflection)
name = self.name
method_name = "belongs_to_touch_after_save_or_destroy_for_#{name}"
touch = options[:touch]
model.redefine_method(method_name) do
record = send(name)
unless record.nil?
if touch == true
record.touch
else
record.touch(touch)
end
end
end
model.after_save(method_name)
model.after_touch(method_name)
model.after_destroy(method_name)
end