Define endpoint to update expenses
This commit is contained in:
parent
f7c0fc91b1
commit
88a7785b46
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user