How do I use a rails link_to helper within a .map block such that the output is an actual link, and not the text representation of the HTML

前端 未结 1 1502
南笙
南笙 2021-01-05 17:04

I have this:

listed in <%= @product.categories.map{ |cat| raw(link_to(cat.name, category_path(cat))) }.join(\', \') + \".\" %>

This i

相关标签:
1条回答
  • 2021-01-05 17:53

    you need to wrap the result of your map call with raw. This way you can tell rails that the string should be outputted directly into the template.

    listed in <%= raw(@product.categories.map{ |cat| raw(link_to(cat.name, category_path(cat))) }.join(', ') + ".") %>
    
    0 讨论(0)
提交回复
热议问题