# 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