0

如何使我使用脚手架生成的用户索引视图的行作为指向显示用户操作的超链接。单击用户行上的任意位置后,它将向我们显示相应的用户。
如果我可以链接到一个部门也是可以接受的。

代码

<table>
  <tr>
  <th>Username</th>
  <th></th>
  <th>email</th>
  <th>roll_no</th>
</tr>

<% @users.each do |user| %>
  <tr >//i want to make these rows as link
    <% if user.username!='admin' %>
      <td><%= user.username %></td>
      <td><%= user.email %></td>
      <td><%= user.roll_no %></td>
      <td><%= link_to 'show', @user %></td><br/>
      <td><%= link_to 'Delete', user, confirm: 'Are you sure?', method: :delete %></td>
    <% end %>
  </tr>
4

1 回答 1

2

正如微薄所说,你应该使用 JavaScript。像这样的东西:

$('tr').click(function(){
    document.location.href='the_link_to_go_to';
})

您可以修改它以满足您的需要。

于 2012-04-10T17:45:20.947 回答