link_to与has_and_belongs_to_many关联

时间:2012-09-16 16:49:26

标签: ruby-on-rails link-to

我在问题中有一个标签列表..现在我想给每个标签一个链接,每个标签中都有相应的问题                                                                                                 标签:

<%= link_to question.tags.map { |t| t.name  }.join("  "), @tag %> </td>

1 个答案:

答案 0 :(得分:0)

试试这段代码

<% question.tags.each do |t| %>
  <%= link_to(t.name, t) + " " %>
<% end %>