나는 컬렉션을 취하는 부분을 가지고 있으며, 개별 항목을 표시하는 컬렉션을 반복합니다. 여기 컬렉션 크기를 기반으로 부분 렌더링을 부분적으로 수행합니다.
코드이다부분 :
<% for point in @points %>
<div id="im" style="float:left;width:80px;height:90px;padding:5px;border:solid 1px #D3D3D3; margin:5px; ">
<img width="80" height="80" src="\uploaded\<%= point.id %>.gif" />
<%= link_to_remote " Delete", :url => { :action => "delete_point", :id => point.id }, :before => "Element.show('spinner')", :complete => "Element.hide('spinner')" %>
</div>
<% end %>
컨트롤러에서 RJS :
page.replace_html :points_partial, :partial => 'points', :collection=>@points
부분이있는 항목의 양에 의해 렌더링되는 어떤 이유 수집. 컬렉션에 항목이 10 개있는 경우 부분을 렌더링 한 다음 시간을 렌더링합니다.
이 남자는 비슷한 문제가 있었지만 레이아웃과 관련이있었습니다. 그것은 간단해야하고 다른 모든 부분 지문이 어떤 어려움없이 작동하기 때문에
Render partial in Ruby on rails a collection is multiplying items
그것은 나를 미친 운전.
내가 다른보기,이 같은 아마 뭔가를 가고 싶어요에 대한 바로 가기로
<%= render @points %>
를 사용할 수 있습니다'@ points.nil 경우? render : action => "index"end' – weltraumpirat부분 이름은 _point.html.erb이어야하며 점/ – weltraumpirat
에 있어야합니다. 또는 다음을 사용할 수 있습니다. object => @points 배열을 부분 배열로 .... 또는. – slotishtype