0
我想显示在第一次循环的特定图像时,部分模板被调用,而不是休息:Ruby on Rails的:渲染收藏
view file:
<% @categories.each do |category,i,category_locales| %>
<div class="featured_deals">
<%= render :partial => "medium_deal", :collection => category_locales, :as => :deal_locale %>
</div>
<% end %>
medium_deal文件:
<% deal = deal_locale.deal %>
<%= image_tag 'layout/featured_deal_left_blue.png', :style => 'float: left; padding-top: 11px;' %>
# I only want this image to show for the FIRST element of category_locales, but not the rest.
<div class="featured_deal_wrapper">
Hello
</div>
我试过在第一个视图文件中传递一个计数器,但是直到“每个”再次通过它才会增加。