What module is needed in ActionController :: Metal to be able to pass a status code for rendering?

I have an Api controller using ActionController :: Metal on Rails 4.1.6 as follows:

class Api < ActionController::Metal
  include AbstractController::Rendering 
  include ActionController::ImplicitRender
  include ActionController::MimeResponds
  include ActionController::RequestForgeryProtection  
  include AbstractController::Callbacks
  include ActionController::HttpAuthentication::Token::ControllerMethods
  include ActionController::Head

  ...
end

However, if I put it in action

render 'not_found', status: 404

It correctly displays the "not_found" template, but returns a status code of 200. Performing the same render in ActionController :: Base, it returns the desired 404. What module am I missing here?

+4
source share
2 answers

try turning on these 3 modules in the same order

include AbstractController::Rendering
include ActionView::Rendering
include ActionController::Rendering
+1
source

Replace this:

include AbstractController::Rendering

with this:

include ActionController::Rendering
0
source

All Articles