这是错误消息及其应用程序跟踪:
NoMethodError in Shopping::OrdersController#index
(the root of error is the application directory.)
undefined method `completed_at' for 2012-08-03 20:24:48 UTC:Time
app/models/coupon.rb:44:in `eligible?'
app/models/coupon.rb:40:in `qualified?'
app/models/coupon.rb:34:in `value'
app/models/order.rb:276:in `coupon_amount'
app/models/order.rb:260:in `find_total'
app/models/order.rb:284:in `credited_total'
app/controllers/shopping/orders_controller.rb:100:in `form_info'
app/controllers/shopping/orders_controller.rb:21:in `index'
但是,当我选择查看完整跟踪时,第一行是
activesupport (3.2.7) lib/active_support/time_with_zone.rb:328:in `method_missing'
我不确定这是控制器的问题还是active_support的问题。有人知道怎么修这个东西吗?谢谢!
在coupon.rb
def qualified?(item_prices, order, at = nil)
at ||= order.completed_at || Time.zone.now
item_prices.sum > minimum_value && eligible?(at)
end
def eligible?(order, at = nil)
at ||= order.completed_at || Time.zone.now
starts_at <= at && expires_at >= at
end
感谢。
答案 0 :(得分:0)
在coupon.rb
的第44行,您正在completed_at
对象上调用Time
。我不知道你的代码是哪一行,但这应该足以让你完成。