我正在使用导轨并绘制一些数据。我使用以下内容:
<%= 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