Skip to content

Commit

Permalink
Fixing off by 1 error
Browse files Browse the repository at this point in the history
  • Loading branch information
kigster committed May 20, 2024
1 parent 0a58e55 commit 93972d2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
1 change: 1 addition & 0 deletions app/controllers/ticket_requests_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ def permitted_params
:password,
:authenticity_token,
:commit,
:_method,
ticket_request: [
:user_id,
:adults,
Expand Down
31 changes: 14 additions & 17 deletions app/views/ticket_requests/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,6 @@
Please list everyone in your party including the kids. We do not (currently) send automated emails to any of the guests you specify.
%p
For adults — please list their full name, and an email address as shown in the below example.
%p
DJs should write their DJ Name, as well as the regular name and email address.
%p
For kids, start with the word "Kid:" and follow up with the name and age, and any optional additional comments.
%p.text-success
%b Examples of good names
%ol
%li DJ Carl Cox (as himself) <[email protected]>
%li John Digweed <[email protected]>
%li Kid: Taylor Swift (11yo kid, requires no supervision)
%li Kid: Jonah Hill (12yo kid with socks untied)
%li Kid: Channing Tatum (5-month old baby, cute and funny)
- list_finalized = (@event.start_time - Time.current) < ::Event::GUEST_LIST_FINAL_WITHIN
- if list_finalized
Expand All @@ -64,21 +51,31 @@
= mail_to '[email protected]'
%br
- else
%h5 Adults
%h4 Adult Guests
%h5 Examples:
%ul
%li DJ Carl Cox (as himself) &lt;[email protected]&gt;
%li John Digweed &lt;[email protected]&gt;
- total_guests = @ticket_request.guest_count
- adult_guests = @ticket_request.adults
- adult_guests.times do |guest_id|
= f.label "Adult Guest #{guest_id + 1}"
- default_value = guest_id == 0 ? @ticket_request.user.name_and_email : ''
= f.text_field :guest_list, readonly: list_finalized, multiple: true, value: Array(@ticket_request.guests[0..adult_guests])[guest_id] || default_value, style: 'width: 80%'
= f.text_field :guest_list, readonly: list_finalized, multiple: true, value: Array(@ticket_request.guests[0...adult_guests])[guest_id] || default_value, style: 'width: 80%'

- if @ticket_request.kids.positive?
%h5 Kids
%h4 Kid Guests
%h5 Examples:
%ul
%li Taylor Swift, 12
%li Jonah Hill, 11
%li Channing Tatum, 4
.small Please enter "Full Name, Age" eg "Justin Bieber, 12"
- kid_guests = @ticket_request.kids
- kid_guests.times do |guest_id|
= f.label "Kid Guest #{guest_id + 1}"
= f.text_field :guest_list, readonly: list_finalized, multiple: true, value: Array(@ticket_request.guests[adult_guests..total_guests])[guest_id + adult_guests], style: 'width: 80%'
= f.text_field :guest_list, readonly: list_finalized, multiple: true, value: Array(@ticket_request.guests[(adult_guests)...total_guests])[guest_id], style: 'width: 80%'


%h5 How are you contributing to the event?
Expand Down

0 comments on commit 93972d2

Please sign in to comment.