我应该如何在rails中禁用我的一些设计flash消息

时间:2014-05-17 05:23:41

标签: ruby-on-rails ruby flash ruby-on-rails-4 devise

如何在rails中禁用我的一些设计flash消息?我在config / locales / devise.en.yml文件中定制了所有设计flash消息。我不想要所有这些。即使我评论或删除其中的一些,我发现那些出现在用户界面中。例如

en:
  devise:
    confirmations:
      confirmed: "Your account was successfully confirmed."
      # send_instructions: "You will receive an email with instructions about how to confirm your account in a few minutes."
      send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions about how to confirm your account in a few minutes."

我在layouts / application.html.erb

中添加了这个
      <% if notice %>
        <p class="alert alert-notice" style="color:#c09853;"><%= notice %></p-->
      <% end %>
      <% if alert %>
        <p class="alert alert-error" style="color:#b94a48;"><%= alert %></p>
      <% end %>

我评论过send_instruction。但是当我运行重启服务器时,它仍然出现在UI中。什么是可能的解决方案?感谢。

1 个答案:

答案 0 :(得分:2)

在devise.en.yml文件中,将每条消息指定为空:

en:
  devise:
    confirmations:
      confirmed: ''
      send_instructions: '' 
      send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions about how to confirm your account in a few minutes."

在你的布局中:

<% flash.each do |key, value| %>
  <%= content_tag :div, value, :class => "flash #{key}" unless value.blank? %>
<% end %>