【发布时间】:2010-04-29 17:57:16
【问题描述】:
我经常使用 ActiveResource,所以我的服务模型只使用 XML。因此,我不需要 respond_to 块,我只是 render :xml => @model
但是我不知道如何使用它来渲染 404 标头。我不得不求助于 respond_to,我认为这增加了一些不必要的方法调用。这是我正在使用的:
respond_to do |format|
if (record_found)
render :xml => @some_record
else
format.xml{ head :not_found }
end
end
但我只想要 render :xml => head :not_found 这样的东西,但它不起作用。谁能告诉我正确的语法?
【问题讨论】:
标签: ruby-on-rails xml rendering http-status-code-404 actioncontroller