Counting page views using the "impressionist" Ruby on Rails gem

I use the impressionist stone to count each impression of each page from people who saw the article, but the problem is that I get it for only one article, and the counter for another is for 0

this is my code

class Article < ActiveRecord::Base
  is_impressionable
end

class ArticlesController < ApplicationController
  impressionist actions: [:show], unique: [:session_hash]
end

This is my show action.

<%= "#{@article.impressionist_count} views" %>
+4
source share
1 answer

Add this code to your controller.

def show
   @article = Article.find
   impressionist(@article)
end
+7
source

Source: https://habr.com/ru/post/1537230/


All Articles