【发布时间】:2019-01-04 13:26:50
【问题描述】:
所以我在 rails 模型中玩范围。
这些查询在开发环境中完美运行,但在生产环境中无法正常运行。
这是我的 Fee 模型,我从中触发 active-record 查询以从 StudentFeeInvoice 模型获取特定发票。
app/models/fee.rb
most_recent_invoice = aStudent.student_fee_invoices.invoices_except_pending_and_adjusted.order(:created_at).last
new_filter_for_invoices = aStudent.student_fee_invoices.invoices_after_specific_date(most_recent_invoice.created_at)"
app/model/student_fee_invoice.rb
scope :invoices_except_pending_and_adjusted, -> {where("status != ? AND status != ?", "Pending", "Adjusted")}
scope :invoices_after_specific_date, -> (created_date) {where('created_at > ?', created_date)}
请纠正我做错了什么。 提前致谢!
【问题讨论】:
-
如果有人要求上下文进一步解释以建立理解,我很乐意解释。
标签: ruby-on-rails activerecord rails-activerecord