我有网站单独的,专用的客户的部分separete,它们具有下/专用路径的工具,并且它们具有所有的控制器都DedicatedController的inheritences。 我想创建一个application_controller的before_filter,以保护该客户从打开不在控制器,继承了dedicated_controlle任何其他页面。

有帮助吗?

解决方案

如果您使用的是before_filter在ApplicationController中,以防止客户去的页面那里你可以在为DedicatedController基本控制器使用skip_filter

因此,对于我们的,我们有:

class ApplicationController
  before_filter :ensure_not_a_customer
  .
  .
end
class Admin::BaseController < ApplicationController
  skip_filter :ensure_not_a_customer
  .
  .
end
class Admin::WebpageController < Admin::BaseController
  .
  .
end

从管理员:: BaseController继承然后什么将跳过从ApplicationController中所述的before_filter。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top