On 12/5/05, gregarican firstname.lastname@example.org wrote:
You closed your controller method with def…end but not the
conditional if…else…end. Add an extra ‘end’ to the bottom of your
code and you should be okay.
Well not necessarily at the end of the code. It should be added in
place right after the else block (the way I indicated in my reply to
your other post, Steven). To see why you can’t just blindly put it at
the end of your code, imagine his class actually looks like the
tasklist = Tasklist.new
tasklist.attributes = @params[“new_tasklist”]
redirect_to(:action => “list”)
render_text"could not add"
# body of other action
Ruby sees the first end after the else as belonging to the if/else.
The definition of other_action then ends up being part of the body of
add_tasklist, and the final end closes the definition of add_tasklist.
The class remains unclosed and that’s what causes the syntax error. If
you add an “end” at the end of the file, you close the class and
remove the syntax error, but the code is still broken, because the
definition of other_action is still local to the body of add_tasklist,
obviously not the desired functionality.