How do I dismiss a Rails flash message after some duration?
ruby, ruby-on-rails
Solution
You can use some simple JavaScript on your page (using jQuery in this example):
$('document').ready(function() {
setTimeout(function() {
$('#flash').slideUp();
}, 3000);
});
Assuming the id of the HTML element holding your flash message is `#flash`, this will slide it up and hide it after 3000 milliseconds (3 seconds).
Problem
I would like to set the number of seconds a flash notice is shown to the user, before it is automatically dismissed.