[英]How to link_to an html anchor tag
I have been trying to make a number of lists where after clicking each list its content gets edited. 我一直在尝试创建一些列表,单击每个列表后,其内容都会被编辑。 I'am using twitter bootstrap, embedded HTML in this Ruby on Rails app. 我正在使用twitter bootstrap,在此Ruby on Rails应用程序中嵌入HTML。
<div class="list-group">
<% @statuses.each do |status| %>
<a href="#" class="list-group-item"><%= status.content %></a>
<% end %>
</div>
Here i did not get how to get these <%= link_to
to get connected with each <a href=""
URL's of the status
. 在这里,我没有得到如何获得这些<%= link_to
获得每个连接<a href=""
的URL的status
。
<%= link_to 'Edit', edit_status_path(status) %>
Please help im totally confused. 请帮助我完全困惑。 Thanks in advance. 提前致谢。
If you want the entire status to actually be a link, like you did with a manual anchor tag in your example, then try: 如果您希望整个状态实际上是一个链接,就像您在示例中使用手动锚标记所做的那样,请尝试:
<div class="list-group">
<% @statuses.each do |status| %>
<%= link_to status.content, edit_status_path(status), class: "list-group-item" %>
<% end %>
</div>
Also see http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to . 另请参阅http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.