Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用rabl生成 json 。设置 json 渲染它没有布局有点令人不安,可能不是正确的方法。它自然没有,也绝对不是基于 HTML 的。
我怎样才能让rails不为json渲染添加布局?或者更一般地说,如何设置布局 MIME 类型的全局策略?
我还没有检查过,但我认为它会起作用:
class ApplicationController < BaseController layout :mime_layout def mime_layout case params[:format] when "json" false .... else "application" end end end