I am trying to set up Devise to return 401 to unauthorized API requests instead of redirects but I’m running into a boulder. This is how I am overriding it’s custom 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 am getting this error:
undefined local variable or method `lookup_context' for #<CustomFailure:0x000001031f6220>
and it points to the respond_to do |format| line
What am I doing wrong?
Devise::FailureApp is inherited form ActionController::Metal which is interacting with Rack on low level, so there is no respond_to view related stuff