class InventoryItem < ActiveRecord::Base

  def subtract_from_inventory(total)
    self.on_hand -= total
    self.save!
    return self.on_hand
  end

  protected
    def validate
      errors.add("on_hand", "can't be negative") unless on_hand >= 0
    end     
end