From a7005c6e8b6e9a3aa53330ebd31fe7d8b065f3b7 Mon Sep 17 00:00:00 2001 From: manson Date: Mon, 16 Jun 2014 15:03:25 +0800 Subject: [PATCH] Removed impressionist counter cache --- app/models/bulletin.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/models/bulletin.rb b/app/models/bulletin.rb index ffb5cc8..e8bdd98 100644 --- a/app/models/bulletin.rb +++ b/app/models/bulletin.rb @@ -16,7 +16,7 @@ class Bulletin # include Tire::Model::Search # include Tire::Model::Callbacks - is_impressionable :counter_cache => { :column_name => :view_count } + is_impressionable field :title, localize: true field :subtitle, localize: true @@ -158,6 +158,10 @@ class Bulletin User.find(self.email_user_ids) rescue [] end + def view_count + Impression.where(:impressionable_id=>self.id).count + end + protected # def clean_values