Skip to content

Commit

Permalink
296 Override default phase presence error for form
Browse files Browse the repository at this point in the history
  • Loading branch information
cpreisinger committed Dec 17, 2024
1 parent c8f02bf commit 0dc5921
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/models/evaluation_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#
class EvaluationForm < ApplicationRecord
belongs_to :challenge
belongs_to :phase
belongs_to :phase, optional: true # Disables default must exist error message
has_many :evaluation_criteria, lambda {
order(:created_at)
}, class_name: 'EvaluationCriterion', dependent: :destroy, inverse_of: :evaluation_form
Expand All @@ -35,6 +35,8 @@ class EvaluationForm < ApplicationRecord
validates :scale_type, presence: true
validates :closing_date, presence: true

# Adds custom error message for phase presence failure instead of default from above
validates :phase, presence: { message: I18n.t("evaluation_form.phase.presence_error") }
validates :phase_id, uniqueness: true

validate :criteria_weights_must_sum_to_one_hundred
Expand Down
3 changes: 3 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ en:
login_error: "There was an issue with logging in. Please try again."
please_try_again: "Please try again."
session_expired_alert: "Your session has expired. Please log in again."
evaluation_form:
phase:
presence_error: "can't be blank"
evaluation_criteria:
duplicate_title_error: "must be unique within criteria"
must_sum_to_100_error: "must sum to 100 with other criteria"
Expand Down

0 comments on commit 0dc5921

Please sign in to comment.