In my application I show messages to users like this way.
<% flash.each do |key, value| %>
<div class="alert alert-<%= key %> alert-dismissible">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<%= value %>
</div>
<% end %>
I have following lines in my application
.alert-notice {
@extend .alert-warning;
}
When I redirect user with redirect_to root_url, :notice => 'messages' everything perfect. Notice message can be seen. However when I direct user with redirect_to root_url, :info => 'messages', No message can be seen. I have debugged code and realised that flash is empty that condition.
It's ok:
redirect_to root_url, :notice => 'messages'
Here is problem:
redirect_to root_url, :info => 'messages'
Any suggestions ?
Thanks.
If you want to use info you have to add this to application_helper.rb
add_flash_types :info
You can add as many extra types as you want, e.g.
add_flash_types :info, :success, :warning, :danger
Extra:
I would also suggest you get used to the new hast notation in Ruby
redirect_to root_url, info: 'messages' # instead of :info => ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With