私はレールに慣れていません: 私のサイド ナビゲーション パーシャルは各ステップを実行し、アイコンとリンクを提供します。現在アクティブなステップで、トップ ナビゲーションにサイド ナビゲーションと同じアイコンを表示したいと考えています。ただし、[i] は別のビューの別のブロックから取得されるため、<%= icon[i] %> は機能しません。i にアクセスせずに、アクティブ リンクのトップのナビゲーションがサイド ナビゲーションと同じアイコン [i] を持つようにするにはどうすればよいですか? 下記参照。
_side_navigation.html.erb
<% icon= ["icon-link", "icon-bar-chart", "icon-edit", "icon-beaker","icon-link", "icon-bar-chart", "icon-edit", "icon-beaker"] %>
<% @step_list.each_with_index do |step, i| %>
<% case step.media_type %>
<% when 'video' %>
<li class="<%= nav_active step %>">
<a href = "
<i class='icon-info-sign icon-2x'></i>
<span>Video</span>
</a>
</li>
<% when 'excel' %>
<li class="<%= nav_active step %>">
<i class="<%= icon[i] %> icon-2x"></i> **<<I need this [i] in the other partial so I know which element of the array is chosen**
<span>Step <%= i %> </span>
</a>
</li>
<% else %>
<li class="<%= nav_active step %>">
<i class="<%= icon[i] %> icon-2x"></i>
<span>Step <%= i %></span>
</a>
</li>
<% end %>
<% end %>
_top_navigation.html.erb
<div class="area-top clearfix">
<div class="pull-left header">
<% case @step.media_type %>
<% when 'video' %>
<h3 class="title">
<i class="<%= icon[i] %>"></i></i> <<<here is the problem since, it does not have access to the current "i" from the other block
Video
</h3>
<h5>
A video for the course is here
</h5>
<% when 'excel' %>
<h3 class="title">
<i class="<%= icon[i] %>"></i></i>
Excel
</h3>
<h5>
Please use the excel sheet below to complete the challenge.
</h5>
<% else %>
<h3 class="title">
<i class="<%= icon[i] %>"></i></i>
Multiple Choice
</h3>
<h5>
Please choose from a selection below
</h5>
<% end %>
</div>