1. Список говнокодов пользователя RubyCoder

    Всего: 1

  2. Ruby / Говнокод #18881

    −34

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    <%
       def out_categories(parent, level)
         if (categ = @categories.where(parent_id: parent))
          categ.each do |cat|
    %>
          <div style='margin-left:<%=level * 20%> px'><%= cat.title %></div>
    <%
          level += 1
          out_categories(cat.id, level)
          level -= 1
          end
         end
       end
       out_categories(nil, 0)
    %>

    Draw tree

    RubyCoder, 16 Октября 2015

    Комментарии (17)