HAML and Ruby loop and UL not working

haml, html, ruby

Solution

The `%li` needs indentation because it is within a `do` block. Even if it is valid markup it will save you debugging time if you opt to use 2 or 4 spaces for indentation for better legibility, as one is very difficult to discern.

%ul.nav.nav-tabs.nav-stacked
  - @courses.each do |c|
    %li
      = link_to "add", { :controller => "admin/relateds", :action => "edit", :id => c.id }, :confirm => "Are you sure?"
      = c.coursetitle

Problem

I'm trying to get this simple list working, but the ul is closing and not enclosing the li elements in the loop. Am I missing a simple way to do this? ``` %ul.nav.nav-tabs.nav-stacked - @courses.each do |c| %li = link_to "add", { :controller => "admin/relateds", :action => "edit", :id => c.id }, :confirm => "Are you sure?" = c.coursetitle ```

Original source