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 @@