1
這裏的錯誤信息和應用程序跟蹤:未定義的方法`completed_at」爲2012-08-03 20時24分48秒UTC:時間
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
感謝。
沒有任何背景的錯誤,它真的很難幫助你。 – 2012-08-04 01:32:46
剛剛添加我的order.rb! – otchkcom 2012-08-04 01:34:14
問題出在您的coupon.rb L44方法符合條件? (請參閱堆棧跟蹤)。你可能在不正確的對象上調用「completed_at」。 – 2012-08-04 01:39:52