2011-11-12 48 views
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> 

我試過在第一個視圖文件中傳遞一個計數器,但是直到「每個」再次通過它纔會增加。

回答