Class: LineItem
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- LineItem
- Defined in:
- app/models/line_item.rb
Instance Method Summary collapse
- #price ⇒ Object
-
#update_quantity(count) ⇒ Object
updates quantity count.
Instance Method Details
#price ⇒ Object
24 25 26 |
# File 'app/models/line_item.rb', line 24 def price product_price * quantity end |
#update_quantity(count) ⇒ Object
updates quantity count. If count is zero then deletes the line_item .
29 30 31 32 |
# File 'app/models/line_item.rb', line 29 def update_quantity(count) count = count.to_i (count > 0) ? update_attributes(quantity: count) : destroy end |