Skip to content

Instantly share code, notes, and snippets.

@brunomichetti
Created August 27, 2019 20:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brunomichetti/ecb78d63898df01b0738e67d84a0a542 to your computer and use it in GitHub Desktop.
Save brunomichetti/ecb78d63898df01b0738e67d84a0a542 to your computer and use it in GitHub Desktop.
class FanInfluencer < ActiveRecord::Base
include Counter::Cache
belongs_to :fan
belongs_to :influencer
counter_cache_on column: :fans_count,
relation: :influencer,
relation_class_name: 'Influencer',
wait: (ENV['CC_DEFERRED_DELAY_SECONDS'] || '20').to_i.seconds,
recalculation: true,
method: :update_fans_count
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment