class ErrorsController < ApplicationController
  skip_before_action :authenticate_user!, raise: false
  skip_before_action :verify_authenticity_token
  # NOTE: Consider using a failsafe errors layout
  # layout 'errors'

  def show
    render status: status, template: "errors/#{status_code}", formats: [:html]
  end

  protected

  def status_code
    params[:code] || :internal_server_error # 500
  end
end

class ErrorsController < ApplicationController
  skip_before_action :authenticate_user!, raise: false
  skip_before_action :verify_authenticity_token
  # NOTE: Consider using a failsafe errors layout
  # layout 'errors'

  def show
    render status: status_code, template: "errors/#{status_code}", formats: [:html]
  end

  protected

  def status_code
    params[:code] || :internal_server_error # 500
  end
end

Fix HTTP status codes for errors
Fix HTTP status codes for errors

Problem: Errors (i.e., 404, 422, 500) returned 200 by mistake

Solution: Return the right error code by calling the right helper method
