Here's the error message and its application trace:
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'
However, when I select to see full trace, the first line is
activesupport (3.2.7) lib/active_support/time_with_zone.rb:328:in `method_missing'
I'm not sure if it's the controller's problem or active_support's problem. Anyone know how to fix this? Thanks!
In 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
Thanks.
On line 44 of coupon.rb
you are calling completed_at
on a Time
object. I don't know which line this is from your code, but that should be enough to get you through.