I am trying to make this behavior with my custom toastr notification
this is what i have
def toast(type, text)
flash[:toastr] = { type => text }
end
I call this in my controller like this
toast('success',"this is a message")
and it would output to my template like so
<% flash[:toastr].each do |type, message| %>
toastr.<%= type %>('<%= message %>')
<% end %>
however it only outputs 1 message
now here is the functionality I am trying to make, which is display multiple flash messages http://tomdallimore.com/blog/extending-flash-message-functionality-in-rails/
it works because of the following method
def flash_message type, text
flash[type] ||= []
flash[type] << text
end
everytime you call #flash_message, it would save the flash message in an array, and I can use for each on the array to display it.
I am having trouble converting my #toast into that, #toast CURRENTLY does this
flash[:toastr] = {'success' => "this is a message"}
I would like to do this
flash[:toastr] = [{'success' => "this is a message'},{'error' => "problem!"}]
Can someone help me modify toast method to accept an array of hashes, and inserts a new hash everytime its called?