Controller code:
def index
  @folders = Folder.where(parent_id: 0, user_id: current_user)
  @subfolders = Hash.new()
  @folders.each_with_index do |folder, index|
    @subfolders[folder.id] = { folder.id => Folder.where(parent_id: folder.id) }
  end
end
View:
<% @folders.each_with_index do |folder, index| %>
  <td><%= folder.name %></td><br />
  @subfolders[index].name
<% end %>
the @subfolders[1].to_s object itself returns this result:
{1=>#<ActiveRecord::Relation [#<Folder id: 2, name: "tt", user_id: 1, created_at: "2014-06-21 19:29:32", updated_at: "2014-06-21 19:29:32", parent_id: 1>]>}
My question is , how to read this @subfolders Hash in view ? I want to display subfolder after parent is displayed... Please help
 
     
    