Skip to content

Commit 14df878

Browse files
committed
Cast the string param to a Boolean
This casts the string param to a bool, allowing a briefer and more idiomatic construction in the InvitationManager#update_attendance method Signed-off-by: jonathan.kerr <[email protected]>
1 parent 31320bb commit 14df878

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

app/controllers/admin/invitations_controller.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ class Admin::InvitationsController < Admin::ApplicationController
22
include Admin::WorkshopConcerns
33

44
def update
5+
truthy_attending = ActiveRecord::Type::Boolean.new.cast(params[:attending])
56
@invitation_manager = Managers::InvitationManager.new(params[:workshop_id], invitation_id, current_user)
67
@workshop = WorkshopPresenter.decorate(@invitation_manager.workshop)
78
authorize @workshop
89
@invitation = @invitation_manager.invitation
9-
message = @invitation_manager.update_attendance(attending: params[:attending], attended: params[:attended])
10+
message = @invitation_manager.update_attendance(attending: truthy_attending, attended: params[:attended])
1011

1112
if request.xhr?
1213
set_admin_workshop_data

app/services/managers/invitation_manager.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def initialize(workshop_id, invitation_id, current_user)
1111
def update_attendance(attending:, attended:)
1212
return update_to_attended if attended
1313

14-
result = attending.eql?('true') ? update_to_attending : update_to_not_attending
14+
result = attending ? update_to_attending : update_to_not_attending
1515
message, error = result.values_at(:message, :error)
1616

1717
unless error

0 commit comments

Comments
 (0)