views:

1161

answers:

3

In Ruby on Rails, I sometimes get an error on the page as:

compile error
/Users/jian/ror/shov2/app/views/stories/index.html.erb:13: syntax error, unexpected kENSURE, expecting ')'
/Users/jian/ror/shov2/app/views/stories/index.html.erb:15: syntax error, unexpected kEND, expecting ')'

the kEND, i can guess that it is End... so it means End of file but unexpected, there should be a ')'.

how about the kENSURE ?

A: 

Check that the delimiters (e.g. <% %> etc.) in your ERB templates match.

John Topley
A: 

keyword ensure from exception handling.

srboisvert
+6  A: 

The kEND constant refers to the token "end", as in what you end every code block with. An ensure block is the equivalent of a finally block in other languages.

begin
  1/0
rescue ZeroDivisionError
  puts "OH SHI-"
ensure # <- THIS THING
  1/1
  puts "Whew, we're safe"
end

That's what kENSURE refers to.

It sounds like you forgot to put the closing paren at the end of either a method call or a method parameter list.

Chuck