Compare commits
2 Commits
ea7cdcf608
...
570e517c28
Author | SHA1 | Date | |
---|---|---|---|
570e517c28 | |||
15e2493f87 |
@ -1,3 +1,7 @@
|
|||||||
// Sassy
|
// Sassy
|
||||||
|
|
||||||
@import "bootstrap";
|
@import "bootstrap";
|
||||||
|
|
||||||
|
.error-message {
|
||||||
|
color: var(--bs-danger)
|
||||||
|
}
|
@ -22,7 +22,7 @@ class CompletionsController < ApplicationController
|
|||||||
redirect_to contest_path(@contest)
|
redirect_to contest_path(@contest)
|
||||||
else
|
else
|
||||||
logger = Logger.new(STDOUT)
|
logger = Logger.new(STDOUT)
|
||||||
logger.info(@completion.errors.full_messages)
|
logger.info(@completion.errors)
|
||||||
@title = "New completion"
|
@title = "New completion"
|
||||||
render :new, status: :unprocessable_entity
|
render :new, status: :unprocessable_entity
|
||||||
end
|
end
|
||||||
@ -42,7 +42,11 @@ class CompletionsController < ApplicationController
|
|||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@completion.destroy
|
@completion.destroy
|
||||||
redirect_to contest_path(@contest)
|
if params[:contestant_id]
|
||||||
|
redirect_to contest_contestant_path(@contest, params[:contestant_id])
|
||||||
|
else
|
||||||
|
redirect_to contest_path(@contest)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -6,4 +6,6 @@ class Completion < ApplicationRecord
|
|||||||
attr_accessor :display_time_from_start, :display_relative_time
|
attr_accessor :display_time_from_start, :display_relative_time
|
||||||
|
|
||||||
validates :time_seconds, presence: true
|
validates :time_seconds, presence: true
|
||||||
|
validates_numericality_of :time_seconds
|
||||||
|
validates :puzzle_id, uniqueness: { score: :contestant }
|
||||||
end
|
end
|
||||||
|
@ -43,8 +43,10 @@
|
|||||||
td
|
td
|
||||||
| #{completion.puzzle.name} - #{completion.puzzle.brand}
|
| #{completion.puzzle.name} - #{completion.puzzle.brand}
|
||||||
td
|
td
|
||||||
a.btn.btn-sm.btn-secondary href=edit_contest_completion_path(@contest, completion, contestant.id)
|
a.btn.btn-sm.btn-secondary.me-2 href=edit_contest_completion_path(@contest, completion, contestant.id)
|
||||||
| Edit
|
| Edit
|
||||||
|
= link_to "Delete", contest_completion_path(contest, completion, contestant_id: contestant.id),
|
||||||
|
data: { turbo_method: :delete }, class: "btn btn-sm btn-secondary"
|
||||||
.row
|
.row
|
||||||
.col
|
.col
|
||||||
a.btn.btn-primary href=new_contest_completion_path(@contest, contestant_id: contestant.id)
|
a.btn.btn-primary href=new_contest_completion_path(@contest, contestant_id: contestant.id)
|
||||||
|
13
config/initializers/form_errors.rb
Normal file
13
config/initializers/form_errors.rb
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
ActionView::Base.field_error_proc = proc do |html_tag, instance|
|
||||||
|
if html_tag.include? "<label"
|
||||||
|
appended_html = ""
|
||||||
|
if instance.error_message.is_a?(Array)
|
||||||
|
appended_html = "<div class='error-message form-text'>#{instance.error_message.map(&:humanize).uniq.join(", ")}</div>"
|
||||||
|
else
|
||||||
|
appended_html = "<div class='error-message form-text'>#{instance.error_message.humanize}</div>"
|
||||||
|
end
|
||||||
|
html_tag + appended_html.html_safe
|
||||||
|
else
|
||||||
|
html_tag
|
||||||
|
end
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user