在ApplicationController中加入以下代码
layout proc{ |c| c.request.xhr? ? false : "application" }
这样对于ajax过来请求render的时候,默认就不会有 layout了。
本文介绍了一种在ApplicationController中配置的方法,通过特定的布局处理器来实现对于Ajax请求默认不使用布局的功能。
在ApplicationController中加入以下代码
layout proc{ |c| c.request.xhr? ? false : "application" }
这样对于ajax过来请求render的时候,默认就不会有 layout了。

被折叠的 条评论
为什么被折叠?