From ec277c14b9a34a81513ff7ef7269adb77ad2a4cf Mon Sep 17 00:00:00 2001 From: Peter Yates Date: Wed, 24 Apr 2024 11:48:57 +0100 Subject: [PATCH] Set param to ecf_id for new API routes (#1322) There's a source of potential confusion where we're dealing with ecf_id and referring to it as id. I think it's clearer if we override param so it's clear exactly what we're referring to. --- app/controllers/api/v3/statements_controller.rb | 4 ++-- config/routes.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/api/v3/statements_controller.rb b/app/controllers/api/v3/statements_controller.rb index d12ad5efab..8a71779ac4 100644 --- a/app/controllers/api/v3/statements_controller.rb +++ b/app/controllers/api/v3/statements_controller.rb @@ -11,7 +11,7 @@ def index end def show - render json: to_json(statements_query.statement(ecf_id: statement_params[:id])) + render json: to_json(statements_query.statement(ecf_id: statement_params[:ecf_id])) end private @@ -25,7 +25,7 @@ def statements_query end def statement_params - params.permit(:id, filter: %i[cohort updated_since]) + params.permit(:ecf_id, filter: %i[cohort updated_since]) end def cohort_start_years diff --git a/config/routes.rb b/config/routes.rb index b853b63733..5e2521d23a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -177,7 +177,7 @@ put :void, path: "void" end - resources :statements, only: %i[index show] + resources :statements, only: %i[index show], param: :ecf_id end end