我有四种类型的 Rawscores 我想在分页表中一起显示。
代码如下所示:
@facebook_scores_today = Rawscore.where(:channel_string => "Facebook", :project => @project, :created_at.gt => Time.now.beginning_of_day)
@youtube_scores_today = Rawscore.where(:channel_string => "Youtube", :project => @project, :created_at.gt => Time.now.beginning_of_day)
@twitter_scores_today = Rawscore.where(:channel_string => "Twitter", :project => @project, :created_at.gt => Time.now.beginning_of_day)
@influence_scores_today = Rawscore.where(:channel_string => "Influence", :project => @project, :created_at.gt => Time.now.beginning_of_day)
Rawscore 有一个具有多个值的哈希作为表的属性,具体取决于:channel_string
.
我该怎么办?任何可以帮助“will_paginate”或“kaminari”的宝石?
更新(这是我的 Rawscore 模型)
class Rawscore
include Mongoid::Document
include Mongoid::Timestamps::Created #for created_at field
belongs_to :channel
belongs_to :project
field :values, type: Hash
validates :values, :presence => true
end
我想在 Rawscore 模型中显示 :values Hash 的键值。