Skip to content

Commit

Permalink
Ensure a nil timestamp_attribute is not added to touch_updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Pheasey committed Oct 15, 2016
1 parent 856a146 commit 325bb0d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/active_touch/touch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@ def initialize(record, association, options = {})
end

def run
touch_updates[ActiveTouch.configuration.timestamp_attribute] = record.updated_at
if !ActiveTouch.configuration.timestamp_attribute.nil?
touch_updates[ActiveTouch.configuration.timestamp_attribute] = record.updated_at
end

if associated.is_a? ActiveRecord::Base
associated.update_columns(touch_updates) if !ActiveTouch.configuration.timestamp_attribute.nil? && !is_touched
associated.update_columns(touch_updates) if !touch_updates.empty? && !is_touched
associated.send(after_touch) unless after_touch.blank?

elsif !associated.nil?
associated.update_all(touch_updates) if !ActiveTouch.configuration.timestamp_attribute.nil? && !is_touched
associated.update_all(touch_updates) if !touch_updates.empty? && !is_touched
associated.each { |associate| associate.send(after_touch) } unless after_touch.blank?
end
end
Expand Down

0 comments on commit 325bb0d

Please sign in to comment.