To_sentence and html_safe together?
Here is the line I want:
<a href="/pugs/1-baxter">Baxter</a> and <a href="/pugs/2-sofia">Sofia</a> Here is the code I use for output:
<%= @pugs.collect {|p| link_to(p.name, pug_path(p))}.to_sentence %> Unfortunately, the result is encoded:
<a href="/pugs/1-baxter">Baxter</a> and <a href="/pugs/2-sofia">Sofia</a> I tried using html_safe and raw , but they don't seem to be affected.
Like Rails 5, the to_sentence helper element (other than Array#to_sentence ) is used there.
From documents :
to_sentence (array, options = {})
Converts an array to a sentence, separated by commas, where the last element is connected to the connecting word. This is the version of ActiveSupport that supports the html_safe Array # to_sentence.
Use it as: <% to_sentence(@pugs.collect {|p| link_to(p.name, pug_path(p))}) %>