In my controller I'm calling @hour.shopper.add_product within a for loop.
My model looks like:
class Shopper < ActiveRecord::Base
attr_accessor :quantity
def add_product
if self.quantity.nil? || \
self.quantity == 0
self.quantity = 1
else
self.quantity += 1
end
self.save
end
end
When I print @hour.shopper.quantity it always says 'nil'. It seems like it's not saving the quantity attribute in the @hour.shopper object.
Thanks in advance!