有人知道查找本月在 Rails 3.1 中创建的记录的最佳查询吗?
最佳答案
class Model
scope :this_month, -> { where(created_at: Time.now.beginning_of_month..Time.now.end_of_month) }
end
你可以这样称呼它:
Model.this_month
关于ruby-on-rails - 如何查找本月在 Rails 3.1 中创建的记录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8197888/