mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-10 17:21:38 -05:00
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
This commit is contained in:
parent
53ec557ec9
commit
09b16ebd7f
1 changed files with 3 additions and 3 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue