Ahmed Reza Siddique
Ahmed Reza Siddique

Reputation: 423

impressionist view count not working

i have a rails app where i am using impressionist gem to count the vieew made on the show page of my post model. But it's not updating the views,(the views shows 0)

in my gem file i added:

gem 'impressionist'

Then:

rails g impressionist

then:

rake db:migrate

i added this to my post.rb file:

   is_impressionable 

post controller

impressionist actions: [:show], unique: [:session_hash]

in my show view file:

<%= "#{@post.impressionist_count} views so far!" %>

I think i have did everything right, but don't know why the view count is not working.

Upvotes: 0

Views: 116

Answers (1)

Chetan Mehta
Chetan Mehta

Reputation: 349

Instead of calling this on top of the controller for a single action you can try:

impressionist(@post, "optional message", :unique => [:session_hash])

Then try

@post.impressionist_count

Or you can also try

@post.impressions_count

Upvotes: 0

Related Questions