module Ahoy::Views::Viewable::ClassMethods

Public Instance Methods

ahoy_viewable() click to toggle source
# File lib/ahoy/views/viewable.rb, line 9
def ahoy_viewable
    has_many :ahoy_views, as: :visited, class_name: 'Ahoy::Event'
    has_many :ahoy_viewers, through: :ahoy_views, source: :visitor

    scope :trending, -> { left_joins(:views).group(:id).order('count(views.id) desc') }

    include Ahoy::Views::Viewable::InstanceMethods
end