简体   繁体   中英

Make clicking a div link to a route or path (Rails 3)

我了解如何使div可点击到特定的URL(即“ http://example.com”),并且正在寻找一种方法来使整个div可点击,并链接到特定路径(即user_path) (用户),:remote => true)。

Answer:

<%= link_to user_path(user), :remote => true do %>
<div class="divname"></div>
<% end %>

This is the basic answer:

Make your link something like "/users/1" to view the user with a primary key of 1.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM