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.
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