Flash is a function that temporarily displays a simple message when a page is changed. For example, when a user successfully logs in, "I was able to log in. ] Is displayed so that the user can check the progress.
1 Basic writing 2 Difference between flash and flash.now
Flash is treated like a hash.
flash[:Key name] =“Message to be displayed”
For the key name, use the previously prepared notice or alert option (you can give it any name you like).
if @outgo.update(outgo_params) flash[:alert] ="Message" has been registered. ’ redirect_to root_path else ~Abbreviation~
Write the following in the place where you want to display the flash message.
<%= flash[:Key name] %>
<%= flash[:alert] %>
--flash is when displaying a flash message in the view file after the next action is taken (when using redirect_to) --flash.now is when you want to display a valid flash message only for the view file displayed by the current action (when using render)