[英]How to display error messages for a devise form? Ruby on rails
<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
<p><%= f.label :email %><br />
<%= f.email_field :email %></p>
<p><%= f.label :password %><br />
<%= f.password_field :password %></p>
<%= end =%>
I am trying to create a basic login form. 我正在尝试创建一个基本的登录表单。 I want to be able to display an error like "wrong user info" if the username or password is incorrect.
如果用户名或密码不正确,我希望能够显示诸如“错误的用户信息”之类的错误。 I looked at this post here: form_for error messages in Ruby on Rails
我在这里看了这篇文章: Ruby on Rails中的form_for错误消息
but it doesn't seem to work for devise forms? 但这似乎不适用于设计形式吗?
First of all you must put notice alerts 首先,您必须发出通知警报
<% if alert %>
<div id="notice_wrapper">
<p class="alert"><%= alert %></p>
</div>
<% elsif notice %>
<div id="notice_wrapper">
<p class="notice"><%= notice %></p>
</div>
<% end %>
i personally use something like this. 我个人使用这样的东西。
To write your own devise errors you must modify it by yourself. 要编写自己的设计错误,必须自己修改。 Devise errors located at:
设计错误位于:
config/locales/devise.en.yml
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.