这看起来很基础,但我是 Ruby/Rails 初学者。我只需要在 Controller 中返回 HTTP 204。 会
respond_to do |format|
format.html
end
返回 204?
最佳答案
head :no_content
使用 Rails 3.2.x、4.x 测试。它会导致 Controller 方法以 204 No Content HTTP 状态代码进行响应。
在名为 foobar
的 Controller 方法中使用它的示例:
def foobar
head :no_content
end
关于ruby-on-rails - 如何在 Rails Controller 中返回 HTTP 204,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8592921/