diff --git a/app/controllers/expenses_controller.rb b/app/controllers/expenses_controller.rb index 0077568..297fa80 100644 --- a/app/controllers/expenses_controller.rb +++ b/app/controllers/expenses_controller.rb @@ -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 diff --git a/config/routes.rb b/config/routes.rb index dd8654a..7e40865 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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