hmiedema9 hmiedema9 - 3 years ago 273
Ruby Question

Unexpected tIDENTIFIER, expecting keyword_do or '{' or '('

This is my Rails code:

def update
if @post.update(post_params)
redirect_to @post, notice: “Update successful”
else
render ‘edit’
end
end


I get an error:

/home/mieds/Documents/Marmelade/app/controllers/posts_controller.rb:34: syntax error, unexpected tIDENTIFIER, expecting keyword_do or '{' or '('

Any ideas on why this is thrown?

Answer Source

There is a problem with your quotes. Change you code with:

def update
  if @post.update(post_params)
    redirect_to @post, notice: "Update successful" # changed here
  else
    render 'edit' # changed here
  end
end
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download