This time, I'm writing a lot of things that I want to remember completely for myself.
PASSWORD_REGEX = /\A(?=.*?[A-z])(?=.*?[\d])[A-z\d]+\z/i.freeze #One or more half-width alphanumeric characters
ZENKAKU_REGEX = /\A[Ah-Hmm-One-龥]+\z/.freeze #Full-width Hirakata Kanji
KANA_REGEX = /\A[A-Car-]+\z/.freeze #full-width Kana
freeze
is to keep variables unchanged.
with_options presence: true do
validates #Add options
end
Call the file with the render method in foem_with. At that time, describe as if it is a file under devise.
<%= form_with model: @user, url: user_registration_path', local: true do |f| %>
<%= render 'devise/shared/error_messages', model: f.object %>
ruby:_error_messages.html.erb
<% if model.errors.any? %>
<div id="error_explanation">
<h2>
<%= I18n.t("errors.messages.not_saved",
count: model.errors.count,
resource: model.class.model_name.human.downcase)
%>
</h2>
<ul>
<%= model.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
Write to call model.
Recommended Posts