【发布时间】:2015-03-18 16:00:02
【问题描述】:
在我的 Ruby on Rails 应用程序中,我有一个模型 Instance,它属于另一个模型 Zone。 Zone 模型本身属于 Country 模型。我正在获取一组Instance 对象,如下所示:
scope :thisweek, -> { joins(:zone).where(zones: {created_at: ...}).includes(:zone)
我想将Country 加入Zone 和Instance,然后根据zone.country.name 字段对结果集Instance 进行排序。谁能帮帮我?
【问题讨论】:
标签: ruby-on-rails ruby activerecord rails-activerecord