Question

I'm getting the following error on the rails server when I press my 'new task' button on my app:

Processing by TasksController#new as JS
ERROR: compiling _app_views_tasks__task_form_html_haml__3289363938348847619_70231363971640 RAISED /app/views/tasks/_task_form.html.haml:4: syntax error, unexpected ')'
));}\n</div>\n<div class='modal-body'>\n  #{
 ^
/app/views/tasks/_task_form.html.haml:8: unknown regexp options - dv
/app/views/tasks/_task_form.html.haml:8: syntax error, unexpected $undefined
));}\n</div>\n<div class='modal-footer'>\n  #{
             ^
/app/views/tasks/_task_form.html.haml:8: syntax error, unexpected keyword_class, expecting keyword_do or '{' or '('
));}\n</div>\n<div class='modal-footer'>\n  #{
                        ^
/app/views/tasks/_task_form.html.haml:8: syntax error, unexpected $undefined
));}\n</div>\n<div class='modal-footer'>\n  #{
                                         ^
/app/views/tasks/_task_form.html.haml:10: syntax error, unexpected '}', expecting keyword_end
));}\n</div>\n", -1, false);::Ham...
    ^

Below is the code on _task_form_html_haml:

.modal-header
    %h1 New Task
    = simple_form_for task, class: 'clearfix' do |f|
.modal-body
    = f.input :title
    = f.input :note
    = f.input :completed
.modal-footer
    = f.submit 'Save', class: 'btn btn-primary'

I've tried to find out more about compiling errors, partials, haml but have had no luck so far. Can anyone point me in the right direction?

Était-ce utile?

La solution

You have this line:

= simple_form_for task, class: 'clearfix' do |f|

that looks like it’s opening a block, but there is nothing indented below it to be the blocks contents.

You just need to correctly indent your code:

.modal-header
    %h1 New Task
    = simple_form_for task, class: 'clearfix' do |f|
        .modal-body
            = f.input :title
            = f.input :note
            = f.input :completed
        .modal-footer
            = f.submit 'Save', class: 'btn btn-primary'
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top