Therefore, for some reason, the following HTML responds only to notice id, not to flash or <%=key%> classes in my CSS. Why is this? In addition, I have a style that should exist depending on whether I show a flash message or not. However, using the notice id for styling, CSS always appears. However, I need a notice identifier for my ajax rendering of a flash message. How can I solve this problem?
<div class="container"> <%= render 'layouts/header' %> <section class="round"> <div id= "notice"> <% flash.each do |key, value| %> <div class="flash <%= key %>"> <%= value %> </div> <% end %> </div> <%= yield %> </section> <%= render 'layouts/footer' %> <%= debug(params) if Rails.env.development? %> </div>
Here's the CSS:
.error, .alert, .notice, .success, #notice, .info { padding:0.8em; margin-bottom:1em; border:2px solid #ddd; } #notice { background:#e6efc2; color:#264409; border-color:#c6d880; }
And here is the corresponding html output. Please note that this is only a div.
<section class="round"> <div id= "notice"></div> </section>
source share