From bedd72a7532a082bc4865e2e2d2d97af5d1c163b Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Tue, 31 Jan 2023 00:29:29 -0800 Subject: [PATCH] Add edit_key to Parties output on create We create a new view `created` that includes the `full` view but adds the `edit_key` param --- app/blueprints/api/v1/party_blueprint.rb | 5 +++++ app/controllers/api/v1/parties_controller.rb | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/blueprints/api/v1/party_blueprint.rb b/app/blueprints/api/v1/party_blueprint.rb index 7424320..6235428 100644 --- a/app/blueprints/api/v1/party_blueprint.rb +++ b/app/blueprints/api/v1/party_blueprint.rb @@ -86,6 +86,11 @@ module Api include_view :preview end + view :created do + include_view :full + fields :edit_key + end + view :destroyed do fields :name, :description, :created_at, :updated_at end diff --git a/app/controllers/api/v1/parties_controller.rb b/app/controllers/api/v1/parties_controller.rb index 76c456f..4de7a7b 100644 --- a/app/controllers/api/v1/parties_controller.rb +++ b/app/controllers/api/v1/parties_controller.rb @@ -26,7 +26,7 @@ module Api # end if party.save! - return render json: PartyBlueprint.render(party, view: :full, root: :party), + return render json: PartyBlueprint.render(party, view: :created, root: :party), status: :created end