Add completion: order contestants by name + add email if present
This commit is contained in:
parent
c34b9654c8
commit
2cadc8eca5
@ -100,7 +100,7 @@ class CompletionsController < ApplicationController
|
||||
end
|
||||
|
||||
def set_data
|
||||
@contestants = @contest.contestants
|
||||
@contestants = @contest.contestants.order(:name)
|
||||
@puzzles = @contest.puzzles
|
||||
end
|
||||
|
||||
|
@ -96,7 +96,7 @@ class MessagesController < ApplicationController
|
||||
end
|
||||
|
||||
def set_data
|
||||
@contestants = @contest.contestants
|
||||
@contestants = @contest.contestants.order(:name)
|
||||
@puzzles = @contest.puzzles
|
||||
end
|
||||
end
|
||||
|
@ -28,6 +28,14 @@ class Contestant < ApplicationRecord
|
||||
validates :name, presence: true
|
||||
validates :time_seconds, presence: true
|
||||
|
||||
def form_name
|
||||
if email.present?
|
||||
"#{name} - #{email}"
|
||||
else
|
||||
name
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def initialize_time_seconds_if_empty
|
||||
|
@ -20,7 +20,7 @@
|
||||
.row.mb-3
|
||||
.col
|
||||
.form-floating
|
||||
= form.select :contestant_id, @contestants.map { |contestant| [contestant.name, contestant.id] }, {}, class: "form-select"
|
||||
= form.select :contestant_id, @contestants.map { |contestant| [contestant.form_name, contestant.id] }, {}, class: "form-select"
|
||||
= form.label :contestant_id
|
||||
- if @puzzles.size > 1
|
||||
.row.mb-3
|
||||
|
Loading…
x
Reference in New Issue
Block a user