Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 使用Desive后,如何在RubyonRails中显示错误消息?_Ruby On Rails_Ruby_Ruby On Rails 3.2 - Fatal编程技术网

Ruby on rails 使用Desive后,如何在RubyonRails中显示错误消息?

Ruby on rails 使用Desive后,如何在RubyonRails中显示错误消息?,ruby-on-rails,ruby,ruby-on-rails-3.2,Ruby On Rails,Ruby,Ruby On Rails 3.2,我制作了一个web应用程序,第一页有电子邮件、密码和确认密码。如果我没有填写它们就输入了,它不会显示任何消息。我该怎么做 <%= devise_error_messages! %> <div><%= f.label :email %><br /> <%= f.email_field :email, autofocus: true %></div> <%= render "devise/shared/links" %

我制作了一个web应用程序,第一页有电子邮件、密码和确认密码。如果我没有填写它们就输入了,它不会显示任何消息。我该怎么做

<%= devise_error_messages! %>

<div><%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %></div>

<%= render "devise/shared/links" %>



假设对象@用户:

<%= form_for(@user) do |f| %>
  <%= f.label :email %>
  <% if @user.errors.any? %>
    ... show the errors the way you want ...
  <% end %>
<% end %>

... 以您想要的方式显示错误。。。

您是否设置了flash消息

<% flash.each do |name, msg| %>
  <%= content_tag :div, msg, class: "flash flash-#{name}" %>
<% end %>

您应该将其放在应用程序视图中的某个位置