From 09b16ebd7f7f6b7b8aef871e5020d18f55f9df61 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 7 Nov 2025 12:52:30 +0000 Subject: [PATCH] Refactor: Use proper boolean casting for sharing parameters - Replace string comparisons ('1', '0') with ActiveModel::Type::Boolean - More robust handling of truthy/falsy values - Follows Rails conventions for type coercion - HTML forms still send string values, but controller properly converts them --- app/controllers/trips_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/trips_controller.rb b/app/controllers/trips_controller.rb index 65f2c4d7..8c3c711a 100644 --- a/app/controllers/trips_controller.rb +++ b/app/controllers/trips_controller.rb @@ -74,11 +74,11 @@ class TripsController < ApplicationController def handle_sharing_update sharing_params = params[:trip][:sharing] - if sharing_params[:enabled] == '1' + if ActiveModel::Type::Boolean.new.cast(sharing_params[:enabled]) sharing_options = { expiration: sharing_params[:expiration] || '24h', - share_notes: sharing_params[:share_notes] == '1', - share_photos: sharing_params[:share_photos] == '1' + share_notes: ActiveModel::Type::Boolean.new.cast(sharing_params[:share_notes]), + share_photos: ActiveModel::Type::Boolean.new.cast(sharing_params[:share_photos]) } @trip.enable_sharing!(**sharing_options)