Rails 4 Click Tracker - Model
class FixtureDownloadTracker < ActiveRecord::Base | |
belongs_to :fixture | |
def self.track(fixture, key) | |
FixtureDownloadTracker.find_or_create_by(fixture: fixture, object_key: key).incr | |
end | |
def self.counter(fixture, key) | |
FixtureDownloadTracker.find_or_create_by(fixture: fixture, object_key: key).download_count | |
end | |
def incr | |
self.download_count += 1 | |
self.save | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment