Counting page views using “impressionist” gem Ruby on Rails

ruby, ruby-on-rails, ruby-on-rails-4

Solution

Add this code in your controller ..

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

Problem

I am using impressionist gem to count each page impression from people who seen article page but the problem is that i get it only work for one article and the counter for the other are 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" %> ```

Original source