I am using controller status:
flash[:notice] = 'message' redirect_to(controller: 'item', action: 'list')
I do not know why the notification does not appear.
I have tried and tested many things:
flash.keepflash.keep[:notice] = 'message'flash[:notice] works fine with renderredirect_to(controller: 'item', action: 'list', notice: 'message')flash.now[:notice] = "Hello world"flash.now['foo'] = "Hello world" with <%= flash['foo'] %> in the view- The layout has <% = flash [: notice]%>
I put the following code in the layout. flash [: notice] works fine when the controller has a view with the same name. The problem occurs when I try to contact another controller that has no view.
<% if !flash[:notice].blank? %> <div class="notice"> <%= flash[:notice] %> </div> <% end %> <% if !flash[:alert].blank? %> <div class="alert"> <%= flash[:alert] %> </div> <% end %>
Can anyone help?
information:
- Ruby (2.0.0)
- Rails (3.2.13)
source share