创建一个“本月”查询栏

时间:2019-02-20 23:59:43

标签: ruby-on-rails sorting date activerecord group-by

我正尝试使用以下代码创建一个查询,以在我的控制器中记录本月的提交情况:

 @today = Time.now

 @thismonth = @today.month

 @nextmonth = @thismonth + 1

 @submissions = SubmissionLocation.includes(:submission).where(location_id: current_agent.Company_Business_Location, location_id: 2134).map(&:submission)

 @submissions_by_group = @submissions.group_by { |m| m.Max_move_in_date.beginning_of_month}.sort_by{:Max_move_in_date}

 @submission_this_month = @submissions_by_group.where(:Max_move_in_date => @thismonth)

@submission_this_month实例变量中的where条件似乎抛出了方法错误。我知道这很可能是因为我的数据现在是哈希格式,所以在那种情况下,我将如何查询呢?

0 个答案:

没有答案