私はレールを使用して、いくつかのデータをグラフ化しています。私は以下を使用します:
<%= column_chart User.includes(:levels).group(:email).sum(:score) %>
このグループ コマンドで、返された配列をスコアの高いものから低いものの順に並べ替えるにはどうすればよいですか?
私のモデルは次のように配置されています
class User < ActiveRecord::Base
has_many :games
contains id, email
end
class Game < ActiveRecord::Base
has_many :levels
belongs_to :user
#contains id, user_id, name
accepts_nested_attributes_for :levels
end
class Level < ActiveRecord::Base
belongs_to :game
#contains id, score and game_id
end