[英]How do I use the Impressionist gem?
I'm using the Impressionist gem. 我正在使用印象派瑰宝。
I want to display a hit counter of one particular page, in that same view. 我想在同一视图中显示一个特定页面的点击计数器。
This is what I did: 这是我所做的:
counter_cache
to the migration. counter_cache
添加到迁移中。 rake db:migrate
. rake db:migrate
。 impressionist :actions=>[:show
] to the controller that I want to track impressions from. impressionist :actions=>[:show
]添加到我要从中跟踪印象的控制器。 is_impressionable :counter_cache => true
to the model pertaining to the controller above. is_impressionable :counter_cache => true
添加到与上述控制器有关的模型。 I have two questions: 我有两个问题:
There is a method to show how much hits: 有一种方法可以显示点击量:
<%= @model_instance.impressionist_count %> views
Put this in your view. 把它放在您的观点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.