Flash message detection not displayed

Devise works fine in my application, with the exception of flash messages from devise.en.yml not showing in the view. What am I doing wrong?

Below is my page view up, I tried both :alert, and :notice, but didn’t work.

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" %>
+5
source share
3 answers

Did you try to pull flash material? Devise_error_messages should take care of them. Mine works without it, and in the original view it doesn’t: https://github.com/plataformatec/devise/blob/master/app/views/devise/registrations/new.html.erb

+3
source

, . , .

, -. , , , . .

flash.now, .

, . -. , , , - , , . -

redirect_to new_user_registrations_path, :notice => "This flash will show up on the sign up page"

- , . , , . , , . , flash.now , . - , / , , , . -

class UsersController < ApplicationController
  def custom_action
    @user = User.find params[:id]
    do_something_with @User
    flash[:user] = "Custom action completed!"
    redirect_to @user
  end
end

/ flash [: custom] - -, , - . - , , .

+6

<% = render: partial = > "shared/flash_messages" % >                       = render 'shared/flash_messages' ( Haml)   , : failure: messages

0

All Articles