How can I make errors in HAML (Rails) show me the exact line where the error occurred?

StackOverflow https://stackoverflow.com/questions/1682431

  •  18-09-2019
  •  | 
  •  

Question

NoMethodError in course_templates#index

Showing app/views/course_templates/index.haml where line #6 raised:

undefined method `new_course_template' for #<ActionView::Base:0x237c3e4>

Extracted source (around line #6):

3: - content_for :sidebar do  
4:   %ul.links  
5:     %li= link_to "Add a Template", new_course_template(@provider)  
6:   
7: - content_for :main do  
8:     = page_entries_info @templates  
9:

See it says "around line #6", and the error is on line 5. This example isn't too bad...but errors in more complex views or in helpers are almost impossible to find right away. Is there a configuration that I'm missing?

Was it helpful?

Solution

This is a bug that I believe should be fixed in the soon-to-be-released Haml 2.2.11. If you wouldn't mind trying this out with the Haml stable branch to see if that makes the line number correct, I would appreciate it greatly.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top