As I delve into learning Rails, I've been immersed in a Rails web app where there is an enticing "Order" button that triggers a response saying: "Thank you for ordering". This message is displayed using the flash action. To enhance user experience, my aim is to make this message fade away after 5 seconds. My solution was to introduce the following code snippet:
$(document).ready(function() {
$("#notice").fadeOut("slow");
});
This script resides within the views/layout directory and is associated with the application.html.erb file in the same location. However, despite my efforts, it seems like it's not functioning as expected. What could be causing this issue and how can I rectify it?