开发者

how to handle multiple error messages in my case?

I have two error message strings, I would like to show them on UI seperately.

flash[:error] = "Error message one"
flash[:error] = "Error message two"

currently, they both flash for a while, and the second error message is hide by the first one.

I would like the "error message one" flash for seconds, and "error message two" is lo开发者_如何学运维cated below "error message one", and stay on the page without disappear. How to do this in rails 3?


You are not limited to flash[:error]. You could for example define

flash[:second] = "Error message two"

and have this displayed in the main layout app/views/layout/application.html.erb with:

<section id="flash">
    <% flash.each do |key, value| %>
        <div class="flash <%= key %>"><%= value %></div>
    <% end %>
</section>

This results in two divs one after the other and if you need to, you can implement a fade-out on the first one using Prototype or JQuery.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜