Rails : Flash Hash

Tanuka Das
2 min readNov 25, 2019

Flash hash is used to display messages when we create, delete, or update a subject.

Inside this create method, we will check if the subject is saved, then used flash to display that the data has been passed and created successfully. I passed the message as a string. We can also pass an object but object uses lots of memory.

We can use this flash hash to display the message in the update or/and delete method. Then we redirected to either show page or index page, which means we’ve to make changes in those files in order to print the message.

Starting with if condition we use .blank? to check if the string of the flash message is empty or not. If it's not empty, print the flash notice. Similarly, we can use the same method to display the flash hash on the show page.

--

--

Tanuka Das

Software Developer, technical writer, bookworm, constant learner.