I am using bootstrap alert to style rails flash messages, but i don't know why it happens
def render_flash_msgs
unless @_flash_rendered
@_flash_rendered = true
render 'shared/flash_msgs'
end
end
# return html class for flash_key
def bootstrap_class_for(flash_key)
flash_key == :notice ? 'alert-info' : "alert-#{flash_key}"
end
I can't post image, so i can just post the html result sources
<div id="flash">
<div class="alert" title="Notice">
<button class="close" data-dismiss="alert">×</button>
<div>Post was successfully updated.</div>
</div>
<!-- dont know why it showed again under the alert block -->
<p id="notice">Post was successfully updated.</p>
Edit :-------------------------------------------------- here is my form
= form_for @post do |f|
- if @post.errors.any?
#error_explanation
h2 = "#{pluralize(@post.errors.count, "error")} prohibited this post from being saved:"
ul
- @post.errors.full_messages.each do |message|
li = message
.field
= f.label :title
= f.text_field :title
.actions = f.submit 'Save'
here is my flash page -----------------------------------
#flash
- flash.each do |type, message|
.alert class=bootstrap_class_for(type)
button.close data-dismiss="alert"
| ×
div = message
Sounds like your alerts are displayed once in layout and once in form. Please show us layout and post _form
partial.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.