【发布时间】:2017-06-19 13:59:08
【问题描述】:
我在 Rails 应用程序 Match 和 Round 中有两个模型如下
Match(id, team1, team2, series_id, event_time, event_lock_time, match_type, created_at, updated_at, match_no, match_stage)
Round(id, series_id, name, description, event_time, event_lock_time, team_ids, matches_count, created_at, updated_at)
我想添加两个表并根据 created_at 对记录进行排序
events = (Match + Round).order('created_at desc').paginate(:page => params[:page], :per_page => params[:per_page])
并且还应用分页。我正在使用 will 分页 gem。
谁能帮助我如何在活动记录中做到这一点。
【问题讨论】:
-
你能分享你的模型吗?它们之间是否有任何关联?
-
不,我在 Match 和 Round 模型之间没有任何关联
标签: ruby-on-rails ruby-on-rails-4