From 53ec557ec92b57e295dbffdcb76f8c0daab2cc76 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 7 Nov 2025 12:50:39 +0000 Subject: [PATCH] Refactor: Nest sharing parameters under trip key MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Follow Rails conventions by nesting sharing params under resource key - Update form fields: sharing[enabled] → trip[sharing][enabled] - Update controller to access params[:trip][:sharing] - Update all request specs to use nested parameters - Parameters now properly structured as trip[sharing][expiration], etc. --- app/controllers/trips_controller.rb | 12 +++++++----- app/views/trips/_sharing.html.erb | 10 +++++----- spec/requests/shared/trips_spec.rb | 18 +++++++++--------- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/app/controllers/trips_controller.rb b/app/controllers/trips_controller.rb index abb9e907..65f2c4d7 100644 --- a/app/controllers/trips_controller.rb +++ b/app/controllers/trips_controller.rb @@ -40,7 +40,7 @@ class TripsController < ApplicationController def update # Handle sharing settings update - if params[:sharing] + if params[:trip] && params[:trip][:sharing] handle_sharing_update redirect_to @trip, notice: 'Trip was successfully updated.', status: :see_other and return end @@ -72,11 +72,13 @@ class TripsController < ApplicationController end def handle_sharing_update - if params[:sharing][:enabled] == '1' + sharing_params = params[:trip][:sharing] + + if sharing_params[:enabled] == '1' sharing_options = { - expiration: params[:sharing][:expiration] || '24h', - share_notes: params[:sharing][:share_notes] == '1', - share_photos: params[:sharing][:share_photos] == '1' + expiration: sharing_params[:expiration] || '24h', + share_notes: sharing_params[:share_notes] == '1', + share_photos: sharing_params[:share_photos] == '1' } @trip.enable_sharing!(**sharing_options) diff --git a/app/views/trips/_sharing.html.erb b/app/views/trips/_sharing.html.erb index 0f0acd47..51f1952e 100644 --- a/app/views/trips/_sharing.html.erb +++ b/app/views/trips/_sharing.html.erb @@ -116,7 +116,7 @@