我有這樣一個電話:如何在.map塊中生成鏈接?
<%= product.categories.map{|cat| cat.name}.join(', ').to_s + "." %>
我想這樣做,是這樣的:
<%= product.categories.map{|cat| link_to cat.name, category_path(cat)}.join(', ').to_s + "." %>
當我做到這一點,它實際上吐出路徑/categories/1
文本和實際上並沒有使它成爲一個鏈接。
如何生成此塊內的實際鏈接?
謝謝。
編輯:任何人有任何想法如何做到這一點?
我想你想映射,然後使用to_sentence像這樣:http://stackoverflow.com/questions/1441328/how-to-use-to-sentence-for-links – jxpx777