ActiveRecord查询按两种方式排序 - 自定义连接?

时间:2016-05-18 23:06:16

标签: mysql ruby-on-rails postgresql activerecord

我目前有以下内容,它计算每个service_provider属于多少用户:

User.where(service_provider_id: self.company.first.id).count

我如何进行自定义连接以使用数据库而不是Ruby来查找在特定日期(即2016年1月1日)之后创建的用户如何属于service_provider?

我有这个,但似乎需要重构,因为两个:

User.
  where(service_provider_id: self.company.first.id).
  where(created_at: Time.now.beginning_of_month..Time.now.end_of_month).
  count

0 个答案:

没有答案
相关问题