2
votes

What is wrong with syntax haml? I used 2 spaces. Display error: /home/user/myapp/bds/app/views/polls/_voting_form.html.haml:14: syntax error, unexpected keyword_ensure, expecting end-of-input

= form_tag votes_path, method: :post, remote: true, id: 'voting_form'
  = hidden_field_tag 'poll[id]', @poll.id

  = render partial: 'polls/poll_item', collection: @poll.poll_items, as: :item  

  %p 
    %b Итого голосов: = @poll.votes_count

  - if current_user.voted_for?(@poll)
    %p Вы уже голосовали!
  - else
    = submit_tag 'Голосовать', class: 'btn-bg'
2

2 Answers

7
votes

I see two errors:

  • you are missing the do on the form_tag line.
  • the second error is not blocking, but for the votes_count: either use string interpolation, or write on multiple lines (now it would just print it as a string)

So easiest solution imho would be to write

%b Итого голосов: #{@poll.votes_count}
2
votes

Here are two errors:

= form_tag votes_path, method: :post, remote: true, id: 'voting_form' # <= missing do
  ....
  %p 
    %b Итого голосов: = @poll.votes_count # <= no valid haml

should be

= form_tag votes_path, method: :post, remote: true, id: 'voting_form' do
  ....
  %p 
    %b 
      Итого голосов:
      = " #{@poll.votes_count}"

You may not prepend normal text to a ruby snippet which requires =. I don't think that there is a compiler that could interprete this. so:

%b= @poll.votes_count # this works
%b Votes count: = @poll.votes_count # this does not

Therefore:

%b 
  Итого голосов:
  = " #{@poll.votes_count}"

or

%b= "Итого голосов: #{@poll.votes_count}"

is the way to go.