The partial file:_link_topic_type.html.erb:
// debug info to check the passed in variables
<p>current_topic_type: <%= current_topic_type %></p>
<p>topic_type: <%= topic_type %></p>
<p>active: <%= current_topic_type == topic_type %></p>
<% if current_topic_type == topic_type %>
<li class="active">
<% else %>
<li>
<% end %>
<%= link_to user.student? ? Topic::TOPIC_TYPES[topic_type] : '我的公告',
topics_path(user_id: user, course_id: course, topic_type: topic_type),
class: 'topic-type-action' %>
</li>
And this file is called 4 times in action view template:
<% (1..4).each do |tt| %>
<%= render partial: 'link_topic_type',
locals: { user: user, course: course, current_topic_type: topic_type, topic_type: tt } %>
<% end %>
From the output, both of the 'current_topic_type' and 'topic_type' value are right, but the 'active' value is always false:
current_topic_type: 1
topic_type: 1
active: false
current_topic_type: 1
topic_type: 2
active: false
current_topic_type: 1
topic_type: 3
active: false
current_topic_type: 1
topic_type: 4
active: false
It is very odd. And i spent 2 hours on it and could not find any hint. Could anyone give some hint?