Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 未初始化的常量ActionController::RedirectBackError您的意思是什么?ActionController::RenderError_Ruby On Rails_Ruby_Rails Routing - Fatal编程技术网

Ruby on rails 未初始化的常量ActionController::RedirectBackError您的意思是什么?ActionController::RenderError

Ruby on rails 未初始化的常量ActionController::RedirectBackError您的意思是什么?ActionController::RenderError,ruby-on-rails,ruby,rails-routing,Ruby On Rails,Ruby,Rails Routing,正在尝试实现重定向\u to:back方法 但我得到了一个错误: 未初始化的常量ActionController::RedirectBackError您的意思是什么?ActionController::RenderError my posts_controller.rb class PostsController

正在尝试实现
重定向\u to:back
方法 但我得到了一个错误:


未初始化的常量ActionController::RedirectBackError您的意思是什么?ActionController::RenderError

my posts_controller.rb

class PostsController将_从ActionController::RedirectBackError中解救出来,使用::将_重定向到_默认值
def发布
post=post.find参数[:id]
发布!
重定向到:返回
结束
私有的
def重定向到默认值
将\重定向到根\路径
结束
结束
我的rails版本是:
6.0.3.3

ruby版本:
ruby 2.7.1p83
dbugger是对的,您可能想试试这个:
redirect\u back(fallback\u位置:根路径)

ActionController::RedirectBackError在Rails 6中不存在。查看Rails 5中引入的更新方式
class PostsController < ApplicationController
  rescue_from ActionController::RedirectBackError, with: :redirect_to_default

  def publish
    post = Post.find params[:id]
    post.publish!
    redirect_to :back
  end

  private

  def redirect_to_default
    redirect_to root_path
  end
end