Messias' answer is the basics of it. Without the quotes around the string, the DOM is stopping the classes when it hits a space. It thinks the other items are attributes on the div tag.
In a best-practices kind of way, we typically want to avoid local assigns (where you set a variable) in the rails view. This really wants to be a helper or a decorator (if you really need that level of functionality and testability).
[The following is pseudo code that I haven't tested, so there may be some minor errors]
In your ERB view:
<% @questions.each do |index| %>
<div class="<%= classy(index) %>" id="[TBD see below]">
<% end %>
I'd suggest finding a more semantic HTML tag than div if possible. Iterators (.each) tend to be a list of objects, so perhaps a UL (unordered list) or OL (ordered list) with LIs inside might be a better choice. ULs give you buttons and OLs give you numbers by default, but those can be changed.
You also probably want to avoid the # sign in a ID name, as you would call an ID in a css file with #name. So #name#2 will likely give you some unexpected and messy results in the DOM. You likely want to use each_ with _index to get both the array and the index value. Pretty good explanation of the differences here: What is the "right" way to iterate through an array in Ruby?
<ul class="questions">
<% @questions.each_with_index do |question,index| %>
<li class="<%= classy(question, index) %>" id="question_<%= index %>">
[CONTENT]
</li>
<% end %>
</ul>
The helper method in whatever_helper.rb (matching the class name or application if site wide):
def classy(question, index)
if index == 0
"tab-pane fade active show"
else
"tab-pane fade"
end
end
And while we're at it, lets get presentation markup out of the view. In your CSS file:
.tab-pane.fade {
height: 444px;
overflow-y: auto;
}
If you're trying to achieve something different, let us know. This was my best guess based on reading the question and code.