Sanskar Pathak
Sanskar Pathak

Reputation: 21

How to hide Rails auto generated flash messages

I am using this to show flash messages in rails

  <% if @article.errors.any? %>
      <h3>Error!</h3>
      <% @article.errors.full_messages.each do |msg| %>
      <ul>
      <li><%= msg %></li>
    </ul>
<%end%>

rails is also showing its generated flashes like

["Description is too short (minimum is 20 characters)"]

on the index page also

Upvotes: 0

Views: 129

Answers (2)

Duhee Lee
Duhee Lee

Reputation: 11

In my local env,

flash.clear

works well.

Upvotes: 1

Guillermo Siliceo Trueba
Guillermo Siliceo Trueba

Reputation: 4619

From the rails docs:

You can use

flash.discard 
flash.discard(:error)

To mark the entire flash or a single flash entry to be discarded by the end of the current action:

Or use

flash.clear

You can find all the methods exposed by rails here.

Upvotes: 0

Related Questions