【发布时间】:2012-01-23 03:47:20
【问题描述】:
我如何为动作控制器创建一个 mixin,它的作用类似于:
layout Proc.new { |controller|
if controller.request.xhr?
'minimal'
else
'application'
end
}
(我不能继承 ApplicationController,因为我使用的是与 ActionController 绑定的 gem(设计)。无论如何,mixin 似乎更合适。)
我创建了一个名为“XHRController”的模块并在 application.rb 中使用了“ApplicationController::Base.include XHRController”,但在任何使用“layout”、“before_filter”等时都会出错,因为未定义。
【问题讨论】:
标签: ruby-on-rails mixins actioncontroller