debt-manager/app/controllers/spendings_controller.rb
Louis Vallat edf60e9557
feat: added spendings for bubbles
Signed-off-by: Louis Vallat <louis@louis-vallat.xyz>
2023-12-31 19:06:33 +01:00

24 lines
572 B
Ruby

# frozen_string_literal: true
class SpendingsController < ApplicationController
def new
@bubble = Bubble.find(params[:bubble_id])
@spending = Spending.new
end
def create
@bubble = Bubble.find(params[:bubble_id])
if @bubble.spendings.new(allowed_params).save
redirect_to bubble_path(@bubble), flash: { success: "Créé" }
else
redirect_to new_bubble_spending_path(@bubble), flash: { error: "Pas créé" }
end
end
private
def allowed_params
params.require(:spending).permit(:amount, :description, :owner_id)
end
end