Define endpoint to update expenses
All checks were successful
Run unit tests / unit_tests (pull_request) Successful in 4m56s
Check usage of free licenses / build-static-assets (pull_request) Successful in 38s
Add copyright notice / copyright_notice (pull_request) Successful in 1m28s

This commit is contained in:
Manuel Bustillo 2024-11-11 08:08:49 +01:00
parent f7c0fc91b1
commit 88a7785b46
2 changed files with 12 additions and 1 deletions

View File

@ -8,4 +8,15 @@ class ExpensesController < ApplicationController
def index
render json: Expense.all.order(pricing_type: :asc, amount: :desc).as_json(only: %i[id name amount pricing_type])
end
def update
Expense.find(params[:id]).update!(expense_params)
render json: {}, status: :ok
end
private
def expense_params
params.require(:expense).permit(:name, :amount, :pricing_type)
end
end

View File

@ -2,7 +2,7 @@
Rails.application.routes.draw do
resources :groups, only: :index
resources :guests do
resources :guests, only: %i[index update] do
post :bulk_update, on: :collection
end
resources :expenses, only: %i[index update] do