Ensure puzzle uniqueness per contestant validation error is shown
This commit is contained in:
parent
9862f0c74b
commit
b6da55723d
@ -36,7 +36,8 @@ class Completion < ApplicationRecord
|
|||||||
before_save :add_time_seconds
|
before_save :add_time_seconds
|
||||||
|
|
||||||
validates :display_time_from_start, presence: true, format: { with: /\A(((\d\d|\d):\d\d|\d\d|\d):\d\d|\d\d|\d)\z/ }
|
validates :display_time_from_start, presence: true, format: { with: /\A(((\d\d|\d):\d\d|\d\d|\d):\d\d|\d\d|\d)\z/ }
|
||||||
validates :puzzle_id, uniqueness: { scope: :contestant }
|
validates :contestant_id, uniqueness: { scope: :puzzle }, if: -> { contest.puzzles.size == 1 }
|
||||||
|
validates :puzzle_id, uniqueness: { scope: :contestant }, if: -> { contest.puzzles.size > 1 }
|
||||||
|
|
||||||
def add_time_seconds
|
def add_time_seconds
|
||||||
arr = display_time_from_start.split(":")
|
arr = display_time_from_start.split(":")
|
||||||
|
@ -82,6 +82,8 @@ en:
|
|||||||
models:
|
models:
|
||||||
completion:
|
completion:
|
||||||
attributes:
|
attributes:
|
||||||
|
contestant_id:
|
||||||
|
taken: "This contestant has already completed the puzzle"
|
||||||
display_time_from_start:
|
display_time_from_start:
|
||||||
blank: Mandatory
|
blank: Mandatory
|
||||||
invalid: "Allowed formats: xx:xx:xx, x:xx:xx, xx:xx, x:xx, xx"
|
invalid: "Allowed formats: xx:xx:xx, x:xx:xx, xx:xx, x:xx, xx"
|
||||||
|
@ -53,6 +53,8 @@ fr:
|
|||||||
models:
|
models:
|
||||||
completion:
|
completion:
|
||||||
attributes:
|
attributes:
|
||||||
|
contestant_id:
|
||||||
|
taken: "Ce.tte participant.e a déjà complété le puzzle"
|
||||||
display_time_from_start:
|
display_time_from_start:
|
||||||
blank: Obligatoire
|
blank: Obligatoire
|
||||||
invalid: "Formats autorisés: xx:xx:xx, x:xx:xx, xx:xx, x:xx, xx"
|
invalid: "Formats autorisés: xx:xx:xx, x:xx:xx, xx:xx, x:xx, xx"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user