我有一个使用 ActionController::Metal on Rails 4.1.6 的 Api 控制器,如下所示:
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
但是,如果我把它付诸行动
render 'not_found', status: 404
它正确呈现“not_found”模板,但返回 200 状态代码。在 ActionController::Base 中运行相同的渲染,它返回所需的 404。我在这里缺少什么模块?
尝试以相同的顺序包含这 3 个模块
include AbstractController::Rendering
include ActionView::Rendering
include ActionController::Rendering
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)