ruby on rails - flash[:alert] not working, but flash[:notice] displays the message on redirect -


i using rails_admin gem , configuration follows

config.authorize_with   if current_user.nil? || current_user.role != 'admin'     redirect_to main_app.root_path     flash[:alert] = "sorry not authorized!"   end end 

when use flash[:notice], can see message on root_path, if change flash[:alert] not display, ideas why , solution?

i want use :alert only, since changing notice color result displaying red font other notices.

it you're not outputting flash[:alert] hash out onto page.

look in views output flash[:notice] (probably in app/views/layouts/application.html.erb (or similar) , copy line notice alert. should this:

<% if flash[:alert] %>       <div id="alert">          <%= flash[:alert] %>        </div> <% end %> 

if doesn't exist (or can't find it), add view (or layout)


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -