1
0
This repository has been archived on 2023-12-07. You can view files and clone it, but cannot push or open issues or pull requests.
body_tracking/app/controllers/ingredients_controller.rb
2020-04-19 21:50:59 +02:00

13 lines
306 B
Ruby

class IngredientsController < ApplicationController
include Concerns::Finders
before_action :find_ingredient, only: [:adjust]
before_action :authorize
def adjust
amount = params[:adjustment].to_i
@ingredient.amount += amount if @ingredient.amount > -amount
@ingredient.save
end
end