Reputation: 1461
I just started playing around with haml and I am trying to understand what I am doing wrong.
articles/edit.html.haml
=render partial: 'form', f: f
.submit_field
=f.submit "Update Article"
articles/_form.html.haml
=form_for @article do |f|
-if @article.errors.any?
#error_explanation
%h2
=pluralize(@article.errors.count, "error")
prohibited this task from being saved:
%ul
[email protected]_messages.each do |msg|
%li=msg
.text_field
=f.label :title
%br
=f.text_field :title
.text_field
=f.label :body
%br
=f.text_area :body, {rows: 10, cols: 40}
I get this error: syntax error, unexpected keyword_ensure, expecting $end at .submit_field . Can anybody point me in the right direction?
Upvotes: 1
Views: 1134
Reputation: 16793
Try moving the submit button in to your form partial:
articles/edit.html.haml
=form_for @article do |f|
=render partial: 'form', f: f
articles/_form.html.haml
-if @article.errors.any?
#error_explanation
%h2
=pluralize(@article.errors.count, "error")
prohibited this task from being saved:
%ul
[email protected]_messages.each do |msg|
%li=msg
.text_field
=f.label :title
%br
=f.text_field :title
.text_field
=f.label :body
%br
=f.text_area :body, {rows: 10, cols: 40}
.submit_field
=f.submit "Update Article"
Upvotes: 1