Merge pull request 'Define endpoint to update expenses' (#119) from update-expenses into main
All checks were successful
Check usage of free licenses / build-static-assets (push) Successful in 1m46s
Run unit tests / unit_tests (push) Successful in 4m28s
Build Nginx-based docker image / build-static-assets (push) Successful in 33m9s

Reviewed-on: #119
This commit is contained in:
bustikiller 2024-11-11 07:23:40 +00:00
commit 402a4a3e5e
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