Is there something I am missing?

placeholder = 0 while(@record_album[placeholder])    temp =@record_album[placeholder]    if(temp.parentid ==      album_tree +="\t<li><a href=\"\#\">#{@record[placeholder]["name"]}</a></li>\n"      placeholder+=1    end end

Ruby has lots of great iterators which can almost always be used in place of such iteration schemes using increments:

@record_album.compact.each do |album|   next unless album.parentid ==   do stuff end

Array#compact will remove any nil entries from your @record_album array (I assume it's an array). Note that the behavior of this one would be different from the original in that the original loop breaks on the first element that is nil or false and this one will simply skip it and continue.

Cheers, Rein