Search code examples
ruby-on-railsruby-on-rails-3devise

Devise flash messages don't show up


Devise works perfectly in my app except for flash messages from devise.en.yml doesn't get displayed in the view. What am I doing wrong?

Below is my sign up page view i have tried both :alert and :notice but not working.

Thank you in advance

<h2>Sign up</h2>

<% if flash[:alert] %>
  <%=flash[:alert]%>
<%end%>

<%= form_for(resource,:as=>resource_name,:url => registration_path(resource_name)) do |f| %>
  <%= devise_error_messages! %>
  <p><%= f.label :Username %></p>
  <p><%= f.text_field :username %></p>

  <p><%= f.label :email %></p>
  <p><%= f.text_field :email %></p>

  <p><%= f.label :password %></p>
  <p><%= f.password_field :password %></p>

  <p><%= f.label :password_confirmation %></p>
  <p><%= f.password_field :password_confirmation %></p>

  <p><%= f.submit "Sign up" %></p>
<% end %>

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

Solution

  • Have you tried taking out the flash stuff ? The devise_error_messages should take care of them. Mine works without it, and the original devise view doesn't have it either: https://github.com/plataformatec/devise/blob/master/app/views/devise/registrations/new.html.erb