Ruby on rails 앱에서 PostgreSQL 데이터베이스에 저장된 이미지로 부트 스트랩 캐로 셀에 이미지를로드하려고합니다. 프론트 엔드에서 ERB를 사용하고 있습니다. 아무것도 아래 코드가 표시와 함께 ... 나는내 삼항 연산자가 데이터베이스의 이미지를 부트 스트랩 캐로 셀에로드하는 ERB의 클래스에서 작동하지 않는 이유는 무엇입니까?
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<% @post.first(3).each do |image, index| %>
<li data-target="#myCarousel" data-slide-to="<%= index %>" class="<%= index == 0 ? 'active' : '' %>"></li>
<% end %>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<% @post.first(3).each do |image, index| %>
<div class="item <%= index == 0 ? 'active' : '' %>">
<%= link_to image_tag(image.image.url, class:"images") %>
<div class="">
<h3><%= index %></h3>
</div>
</div>
<% end %>
</div>
<!-- Left and right controls -->
<a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
도움이 될 경우 대답을 수락 할 수 있습니까? – Gabbar
여기의 인덱스 변수는 nil입니다. 각 오브젝트 대신 반복적으로 each_with_index를 사용하십시오. –