我目前有以下内容,它计算每个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