I'm implementing a simple API in my application to communicate with an Android application. I'm trying to use AbstractController::Metal mainly for performance. The problem I'm having is that render is ignoring the status option that I'm passing.
Very simple example:
class Api::V1::ApiController < ActionController::Metal
include AbstractController::Rendering
include ActionController::Renderers::All
include ActionController::RackDelegation
include ActionController::MimeResponds
end
class Api::V1::SessionsController < Api::V1::ApiController
def show
render status: :unauthorized # using 401 yields the same result
end
end
Calling
curl -v -X GET http://app.dev:3000/api/v1/sessions.json
I'd expect to receive a 401 but instead I get a 200 OK:
> GET /api/v1/sessions.json HTTP/1.1
> User-Agent: curl/7.30.0
> Host: app.dev:3000
> Accept: */*
>
< HTTP/1.1 200 OK
Any ideas? Overwriting response.status is the only work around I've found so far, but honestly it looks like an ugly hack.
Thank you in advance for your insights.