Reputation: 1093
Here is my link_to helper:
<%= link_to pdf.title, pdf.file.url(:original, false), target: :_blank %>
This produces the following html:
<a target="_blank" href="/system/pdfs/files/000/000/005/original/cv.pdf">my pdf file!</a>
How can I print the same html in view?
What I tried:
Method
<%= debug (link_to pdf.title, pdf.file.url(:original, false), target: :_blank) %>
This produces the correct html. However, the html is displayed within a grey box.
I just need the string. I don't want the grey box, the dots or the hyphens. Further, someone noted that debug
might not work in production.
Method
<%= (link_to pdf.title, pdf.file.url(:original, false), target:
:_blank).inspect %>
This produces faulty html. As you can see, characters are escaped:
"<a target=\"_blank\" href=\"/system/pdfs/files/000/000/005/original/cv.pdf\">CV</a>"
Any suggestions?
Upvotes: 1
Views: 258
Reputation: 9826
You don't need debug
, you can just convert it into a string. For example:
<%= "#{link_to 'Google', 'https://google.com', target: '_blank'}" %>
This will output the following to the page:
<a target="_blank" href="https://google.com">Google</a>
Upvotes: 1