fixed various error messages
This commit is contained in:
parent
df6175ce86
commit
4a20c579ed
@ -45,7 +45,7 @@ class CandidateController < ApplicationController
|
||||
|
||||
def validate
|
||||
candidate = Candidate.find_by(test_hash: params['test_id'])
|
||||
redirect_to(root_path, alert: "Sorry, incorrect test id") and return if candidate.nil?
|
||||
redirect_to(root_path, flash: { error: "Sorry, incorrect test id" }) and return if candidate.nil?
|
||||
|
||||
session[:test_id] = candidate.test_hash
|
||||
redirect_to :thankyou and return if candidate.completed?
|
||||
|
@ -10,7 +10,7 @@ class EmailFormatValidator < ActiveModel::EachValidator
|
||||
end
|
||||
|
||||
if results.include?(false)
|
||||
record.errors[attribute] << (options[:message] || "is not formatted properly: #{value}")
|
||||
record.errors[attribute] << (options[:message] || "is not formatted properly")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -38,6 +38,10 @@
|
||||
<div class="form-group">
|
||||
<label for="userid">What's your User ID?</label>
|
||||
<input type="text" id="test_id" name="test_id" required/>
|
||||
|
||||
<% if flash[:error].present? %>
|
||||
<div class="error"><%= flash[:error] %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
<button type="submit">Begin</button>
|
||||
<% end %>
|
||||
|
@ -4,9 +4,11 @@
|
||||
<% if flash[:error].present? %>
|
||||
<div class="error">
|
||||
<%= flash[:error] %>
|
||||
<p>
|
||||
<% @candidate.errors.messages.each do |k,v| %>
|
||||
<p><%= "#{k}: #{v}" %></p>
|
||||
<%= "#{k.to_s} #{v.join(' and ')}" %><br />
|
||||
<% end %>
|
||||
</p>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
@ -27,6 +29,6 @@
|
||||
</div>
|
||||
|
||||
<%= form.hidden_field :quiz_id, { value: Quiz.first.to_i } %>
|
||||
<%= submit_tag "Login" %>
|
||||
<%= submit_tag "Save" %>
|
||||
<% end %>
|
||||
</main>
|
||||
|
Loading…
Reference in New Issue
Block a user