I use a simple API in my application to communicate with the Android application. I am trying to use AbstractController :: Metal mainly for performance. The problem I am facing is that the renderer ignores the status parameter that I pass.
A 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
Call
curl -v -X GET http://app.dev:3000/api/v1/sessions.json
I expect to get 401, but instead get 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 I have found so far, but to be honest, it looks like an ugly hack.
Thanks in advance for your understanding.
ruby ruby-on-rails rack render
Felipe koch
source share