ruby on rails - Override the values in the method -
i have online store. there column price(using gem money). , there column "discount". , if store manager records price in column "discount", store needs display price(column "discount") think need override "price" in model. don't know how access column "price"?
class item < activerecord::base monetize :price_cents monetize :discount_cents def price if self.discount > 0 self.discount else ? if call, self.price turns out called once again method. self[:price] = nil, why? end end end
super
may work, or consider using decorators kind of stuff.
Comments
Post a Comment