I'm trying to configure Devise to return 401 to unauthorized API requests instead of redirecting, but I'm running into a boulder. Here's how I override this user failure behavior:
class CustomFailure < Devise::FailureApp
include ActionController::Head
include ActionController::MimeResponds
def respond
respond_to do |format|
format.html {
super
}
format.any { head :status => 401}
end
end
end
However, I get this error:
undefined local variable or method `lookup_context' for #<CustomFailure:0x000001031f6220>
and points to the line respond_to do |format|
What am I doing wrong?
source
share