我有以下代码:
def edit
@post = Post.find(params[:id])
if !current_user.posts.include?(@post)
permission_denied
end
respond_to do |format|
format.html # edit.html.erb
format.json { render :json => @post }
end
end
def permission_denied
flash[:notice] = 'Sorry, you are not authorized to access that page.'
redirect_to root_url
end
如何调整此代码,因此它不会显示“在此操作中多次调用渲染和/或重定向”。我尝试将“并返回”添加到redirect_to root_url and return
,但我不断收到相同的错误。