Sha256: b1bb18642f7fe3f0d30985ad40412a90b47dd3705d5813a124fc41b0ea389f63

Contents?: true

Size: 558 Bytes

Versions: 2

Compression:

Stored size: 558 Bytes

Contents

class Impression < ActiveRecord::Base
  attr_accessible :impressionable_type, :impressionable_id, :user_id,
  :controller_name, :action_name, :view_name, :request_hash, :ip_address,
  :session_hash, :message, :referrer

  after_save :update_impressions_counter_cache

  private

  def update_impressions_counter_cache
    impressionable_class = self.impressionable_type.constantize

    if impressionable_class.counter_cache_options
      resouce = impressionable_class.find(self.impressionable_id)
      resouce.try(:update_counter_cache)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
impressionist-1.1.1 lib/impressionist/models/active_record/impression.rb
impressionist-1.1.0 lib/impressionist/models/active_record/impression.rb