Merge pull request 'Define endpoint to update expenses' (#119) from update-expenses into main
Reviewed-on: #119
This commit is contained in:
commit
402a4a3e5e
@ -8,4 +8,15 @@ class ExpensesController < ApplicationController
|
|||||||
def index
|
def index
|
||||||
render json: Expense.all.order(pricing_type: :asc, amount: :desc).as_json(only: %i[id name amount pricing_type])
|
render json: Expense.all.order(pricing_type: :asc, amount: :desc).as_json(only: %i[id name amount pricing_type])
|
||||||
end
|
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
|
end
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
Rails.application.routes.draw do
|
Rails.application.routes.draw do
|
||||||
resources :groups, only: :index
|
resources :groups, only: :index
|
||||||
resources :guests do
|
resources :guests, only: %i[index update] do
|
||||||
post :bulk_update, on: :collection
|
post :bulk_update, on: :collection
|
||||||
end
|
end
|
||||||
resources :expenses, only: %i[index update] do
|
resources :expenses, only: %i[index update] do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user