Instead of marking the flash value as html_safe
it is better to proper sanitize it when presenting in your view. I believe <%= sanitize(flash[:notice) %>
would work fine.
I believe due to this change: https://github.com/rails/rails/pull/13945#issuecomment-34090370 we're no longer able to set html_safe strings in the flash message. Is this a bug? Does anyone have an opinion on the right way set a flash message with a link in it now?-Justin
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-co...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
Visit this group at http://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.
It doesn’t work on Rails 4.1 due the way flash are stored now by default.
In Rails 4.1 the default is to store cookies (and for consequence the flash) using JSON serialization, this serialization doesn’t store complex objects like ActiveSupport::SafeBuffer
, a model instance, etc. This is the reason it doesn’t save the HTML safety of your string.
You still can use the old Marshal serialization configuring it in your application. That would bring back the possibility to store HTML safe strings on the flash but it is also less secure than the JSON serializer.