I am starting to learn ruby on rails, like it so far. But I have a hard time wrapping my head around those flash-sessions.
I would rather have it working something like:
flash[:alert] << "first alert message"
flash[:alert] << "second alert message"
But, it doesn’t work (edit: since flash[:alert] isn’t an array). A solution would be to initiate flash[:alert] as an empty array in some kind of construct, i tried it in a before_filter but didn’t get it to work.
Any ideas?
Edit:
As I’ve written in some comments. What i am trying to do is find a place to convert flash[:alert] to an array. In some sort of construct. If i do it before i call flash[:alert] i have to know when i will be doing it the first time so i won’t overwrite anything I allready have in it.
You could write a helper method in your application controller. For example, like this:
Then in your view loop over
flash[:alert]and build your markup.