Class: Integral::PostViewing
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Integral::PostViewing
- Defined in:
- app/models/integral/post_viewing.rb
Overview
Represents when a visitor views a post. Keeps track of unique view count based on IP address
Class Method Summary collapse
-
.add(post, ip_address) ⇒ Boolean
Adds a post viewing if it does not already exist.
Class Method Details
.add(post, ip_address) ⇒ Boolean
Adds a post viewing if it does not already exist
12 13 14 15 16 17 |
# File 'app/models/integral/post_viewing.rb', line 12 def self.add(post, ip_address) return false if where(post: post, ip_address: ip_address).exists? create!(post: post, ip_address: ip_address) true end |