我正在尝试在锚标记内放入rel和class属性,但它会继续进入img标记。我对Rails很新,所以我希望能看到我做错了什么。
<% @series.uploads.each do |upload| %>
<%= link_to image_tag upload.upload.url(:thumb), :class => 'lightbox', :rel => 'lightbox'%>
<% end %>
这是输出。
<a href="/project-gallery">
<img alt="alt" class="lightbox" rel="lightbox" src="img-path" />
</a>
答案 0 :(得分:2)
此?
<%= link_to(image_tag(upload.upload.url(:thumb)), :class => 'lightbox', :rel => 'lightbox') %>
答案 1 :(得分:0)
这就是我最终要做的就是让它发挥作用,但它看起来不正确?
<% @series.uploads.each do |upload| %>
<%= link_to(image_tag(upload.upload.url(:thumb)), '', {:rel => "lightbox", :class => "lightbox"})%>
<% end %>