I would handle this differently.
flash[:welcome] = "Welcome to my site!" flash[:notice] = "I am happy to have you!"
Then in the view do:
That will not just iterate your flash messages, but you can style each type with css. It will output divs with the flash :key as the class name.
Chris ur absolutely right nl2br is a PHP fn , i just messed it up :(
Instead of using nl2br Try this boss flash[:notice].gsub(/\n/, "break")
( BR tag is parsed by the text editor so i have used the text 'break', please replace it with html br tag )
Thanks for your inputs.
I have tried both the ideas, but couldn't reached the expected.
Thank you very much for your reply. it worked for me. but the messages are not displaying in line by line. They are displaying as a continuous string.
I did the same as you suggested.
In the view i am displaying the flash by the statement:
Please do the needful.
I am not very clear about your question. If you want to display combination of messages in the flash notice , you can just have an array to store all the flash messages you need and at the end just join them by a new line character and then assign it to the flash.
messages = Array.new messages << â€œHi, welcome..â€ messages << â€œHi, welcome..to my website.â€ .....
flash[:notice] = messages.join('\n')
Could any one let me know how to setup the flash system available in Rails, to display mutiple messages at a time on the view.
flash[:notice] = "Hi, welcome.." flash[:notice] = "Hi, welcome..to my website."
i wanted these two messages displayed in the Next page.How it can be done?Please help me out.