我有四種類型的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有多個值atributes爲根據: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模型值散列。
我需要顯示各類型Rawscore的一個屬性。我如何實現這一目標? –
所有屬性都在Hash of Rawscore模型中。我如何顯示它們? –
請用您嘗試顯示模型的代碼更新您的問題。我不明白你想要什麼。 – MikDiet