uninitialized constant ActionController::RedirectBackError Did you mean? ActionController::RenderError

Viewed 478

Trying to implement redirect_to :back method but I'm getting this error:

uninitialized constant ActionController::RedirectBackError Did you mean? ActionController::RenderError

my posts_controller.rb

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

my rails version is: 6.0.3.3 and ruby version: ruby 2.7.1p83

1 Answers

dbugger is right you might want to try this instead : redirect_back(fallback_location: root_path)

Related