问题描述
如何在视图代码周围环绕链接?我不知道如何将带有 ruby 代码的多行传递给单个 link_to
方法.我正在寻找的结果是您单击该列并获得显示页面:
<div class="c25l"><div class="subcl">图像"救援 nil %>
如何在视图代码周围环绕链接?我不知道如何将带有 ruby 代码的多行传递给单个 link_to
方法.我正在寻找的结果是您单击该列并获得显示页面:
<div class="c25l"><div class="subcl">图像"救援 nil %>
<div class="c75r"><div class="subcr"><p><%=专辑.created_at%></p><%=link_to h(album.title),专辑%><p><%=专辑.created_at%></p><p><%=专辑.photo_count%></p>
link_to
接受一段代码(>= Rails 2.2),它将用作标签的主体.
所以,你这样做
html-code-here<%结束%>
但是我很确定在 a
标签内嵌套一个 div
是无效的 HTML.
根据 Amin Ariana 下面的评论添加了 =
字符.
How do I wrap a link around view code? I can't figure out how to pass multiple lines with ruby code to a single link_to
method. The result I am looking for is that you click the column and get the show page:
<div class="subcolumns">
<div class="c25l">
<div class="subcl">
<%= image_tag album.photo.media.url(:thumb), :class => "image" rescue nil %>
</div>
</div>
<div class="c75r">
<div class="subcr">
<p><%= album.created_at %></p>
<%= link_to h(album.title), album %>
<p><%= album.created_at %></p>
<p><%= album.photo_count %></p>
</div>
</div>
</div>
link_to
takes a block of code ( >= Rails 2.2) which it will use as the body of the tag.
So, you do
<%= link_to(@album) do %>
html-code-here
<% end %>
But I'm quite sure that to nest a div
inside a a
tag is not valid HTML.
EDIT: Added =
character per Amin Ariana's comment below.
这篇关于如何将 link_to 包裹在一些 html ruby 代码中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!