【发布时间】:2011-04-09 23:36:14
【问题描述】:
代码
respond_to do |format|
format.html
format.json { render :json => @switches }
format.xml { render :xml => @switches.to_xml }
format.all { render :text => "only HTML, XML, and JSON format are supported at the moment." }
end
以上内容适用于 Rails 2.2.2。但在 Rails 3 中,在浏览器上获取 controller/index.html 或 index 都会落入最后一行:“目前仅支持 HTML 和 JSON 格式。”
我能找到的唯一 Rails 文档是
目前仅规定:
respond_to :html, :xml, :json
但他们需要单独的 json 和 xml 模板,并且无法处理“目前仅支持 HTML 和 JSON 格式”的情况。
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-3 mime