Non*_*nos 56 ruby ruby-on-rails
这似乎是基本的,但我是Ruby/Rails的初学者.我需要简单地在控制器中返回HTTP 204.将
respond_to do |format|
format.html
end
Run Code Online (Sandbox Code Playgroud)
返回204?
Eli*_*kes 97
head :no_content
Run Code Online (Sandbox Code Playgroud)
使用Rails 3.2.x,4.x进行测试.它使控制器方法响应204 No Content HTTP状态代码.
在名为的控制器方法中使用它的示例foobar
:
def foobar
head :no_content
end
Run Code Online (Sandbox Code Playgroud)
如果你不想渲染任何东西,你可以这样做:
render :nothing => true, :status => 204
Run Code Online (Sandbox Code Playgroud)
或者像这样:
render :nothing => true, :status => 204 and return
Run Code Online (Sandbox Code Playgroud)
或者您可以将该:status => 204
部件与任何其他渲染命令一起使用
归档时间: |
|
查看次数: |
27313 次 |
最近记录: |