Reputation: 643
In my application.html.erb file, I have:
<div class="container">
<% flash.each do | type, message | %>
<div class="alert <%= flash_class(type) %>">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span></button>
<%= message %>
</div>
<% end %>
<%= yield %>
</div>
I have the flash_class as a helper method:
module ApplicationHelper
def flash_class(type)
case type
when :alert
"alert-error"
when :notice
"alert-success"
else
""
end
end
end
Though what happens is the class isn't being appended in the HTML. When I create an error, the 'alert-error' class isn't added on:
Any ideas why that might be the case?
Upvotes: 0
Views: 75
Reputation: 648
You might be sending in String
for type instead of Symbol
in the flash_class
method.
An easy fix would be calling type.to_sym
in the flash_class
helper method.
Upvotes: 1