Ruby:将项目数组更改为ERB中的链接

时间:2014-10-09 22:46:19

标签: ruby-on-rails ruby

我有一个字符串数组,我想插入erb文件中的链接。 我将如何处理这种语法?

目前,我有以下

    <% names.each do |name| %>
<b>
    <%=name%>
</b>
<%end%>

<% navigation=["home","about us","store","contact","blog"] %>
<%navigation.each do |navitem| %>
    <ul>
        <li>
            <a href= <%=/#{navitem}/%>".html">
        <%=navitem%>
            </a>
        </li>
    </ul>
    <%end%>

1 个答案:

答案 0 :(得分:2)

更改

<a href= <%=/#{navitem}/%>".html">

<a href="<%= navitem %>.html">