[英]rails 3.2 scope combination with impressionist gem
I have impressionist gem in my rails application and i want to create a scope to return the most viewed item, by adding is_impressionable
to the model i am able to return the view counts (as in number of views) on the resource using object.impressionist_count
method but i dont know how to create a scope in my model for most viewed object. 我在Rails应用程序中有印象派宝石,我想创建一个范围以返回观看次数最多的项目,方法是将is_impressionable
添加到模型中,以便能够使用object.impressionist_count
返回资源上的视图计数(与视图数相同)方法,但我不知道如何在模型中为大多数查看对象创建范围。 the table name created by impressionist gem
is impressions
Your help will be very much appreciated Thanks impressionist gem
创建的表名是impressions
我们将非常感谢您的帮助
You can create a model, for example CustomImpression and set the table: 您可以创建一个模型,例如CustomImpression并设置表:
class CustomImpression < ActiveRecord::Base
set_table_name 'impressions'
belongs_to :user
scope :my_custom_scope, ...
def my_custom_function
...
end
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.