如何使我使用基架生成的用户索引视图的行作为显示用户操作的超链接。 单击用户行上的任意位置后,它将向我们显示相应的用户。 如果我可以链接到一个部门,这也是可以接受的。
法典
<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>
正如 Meager 所说,你应该使用 JavaScript。像这样:
$('tr').click(function(){
document.location.href='the_link_to_go_to';
})
您可以对其进行修改以满足您的需求。