How do I sort in ruby/rails on two fields?

后端 未结 5 482
星月不相逢
星月不相逢 2020-12-14 05:59

For example, I would like to sort by game_date, and then if the date is the same, sort it by team? What would be the best way to do this?

@teams = @user.tea         


        
5条回答
  •  有刺的猬
    2020-12-14 06:41

    @teams = @user.teams 
    @games = @teams.games.order(game_date: :asc, team: :asc)
    

提交回复
热议问题