[英]How to link_to just by ID number in rails
I'm trying to link to a specific database item by just the id number itself, instead of doing something like this:我正在尝试仅通过 ID 号本身链接到特定的数据库项,而不是执行以下操作:
<%= link_to locations_path(@location) do %>
<li class="border-top border-bottom">Location</li>
<% end %>
I would like to link by the id number manually, something like this:我想手动通过 ID 号链接,如下所示:
<%= link_to locations_path(82) do %>
<li class="border-top border-bottom">Location</li>
<% end %>
Thanks in advance!提前致谢!
Try this code:试试这个代码:
<%= link_to location_path(82) do %>
^^^^^^^^^^^^^^
<li class="border-top border-bottom">Location</li>
<% end %>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.