意外的tIDENTIFIER,期待keyword_do或'{'或'(''

时间:2017-10-02 05:15:35

标签: ruby

这是我的Rails代码:

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

我收到错误:

/home/mieds/Documents/Marmelade/app/controllers/posts_controller.rb:34:语法错误,意外的tIDENTIFIER,期待keyword_do或'{'或'('

有关为什么抛出此事的任何想法?

2 个答案:

答案 0 :(得分:2)

您的报价存在问题。用以下代码更改代码:

def update
  if @post.update(post_params)
    redirect_to @post, notice: "Update successful" # changed here
  else
    render 'edit' # changed here
  end
end

答案 1 :(得分:0)

尝试使用以下内容:

redirect_to posts_path, notice: "Update successful"