Impressionist Pearls and Friendly_id

I have a Rails application with an impressionist and a friendly identifier, I want to show pageviews in my articles. The problem is that the impressionist does not record the number of views.

This is the same issue here on the impressionist tracker .

My article model:

class Article < ActiveRecord::Base
  is_impressionable
  extend FriendlyId
  friendly_id :title, use: [:slugged, :history]
  belongs_to :user
  belongs_to :category

Article Controller:

def show
  @article = Article.find(params[:id])

  if request.path != article_path(@article)
    redirect_to @article, status: :moved_permanently
  end
  respond_to do |format|
     format.html 
     format.json { render json: @article }
  end    
end

I also restarted the server but had the same problem.

+3
source share
2 answers

Well, there is work. Just add impressionist (@model) to show manager

def show
  @article = Article.find(params[:id])
  impressionist(@article)

   if request.path != article_path(@article)
      redirect_to @article, status: :moved_permanently
   end
   respond_to do |format|
    format.html 
    format.json { render json: @article }
  end    
end
+9
source

A little tip for unique functionality:

def show
  @article = Article.find(params[:id])
  impressionist(@article, nil, { unique: [:session_hash] })
end
+1
source

All Articles