开发者

Block List Question

开发者 https://www.devze.com 2022-12-19 23:22 出处:网络
I have the following code in one of my views: <% @videos.each do |i| %> <tr class=\"<%= cycle(\"even\",\"odd\") %>\">

I have the following code in one of my views:

<% @videos.each do |i| %>
    <tr class="<%= cycle("even","odd") %>">
      <td><%= i.title %></td>
      <td><%= i.premiere %></td>
      <td><开发者_运维技巧%= i.film_type %></td>
      <td><%= i.preferred_date %></td>
      <td><%= i.actual_date %></td>
      <td><%= i.created_at %></td>
      <td><%= i.updated_at %></td>
      <td><%= i.size %></td>
    </tr>
    <% end %>

It is listing all of the items in a table (which is then sortable) from each video. I want to make the title link to the video that the title belongs to. Could someone please show me how to make i.title into a link? I tried lots of formats and none of them seem to work.

Thank you!


To link to Rails' standard "show" action for the video:

<td><%= link_to(i.title, video_path(i)) %></td>

This assumes that i.class == Video and you have map.resources :videos in your routes.

0

精彩评论

暂无评论...
验证码 换一张
取 消