试图将rel和class放在rails link_to中

时间:2013-03-21 23:47:24

标签: ruby-on-rails image rel

我正在尝试在锚标记内放入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>

2 个答案:

答案 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 %>