2012-09-28 12 views
0
class ApplicationController < ActionController::Base 
    def func 
    end 
end 

class BaseController < ApplicationController 
    def func(a) 
    end 
end 

class MyController < BaseController 
    before_filter :funC# I want this to call ApplicationController::func 
end 

在這種情況下,調用BaseController :: func。我如何調用ApplicationController的?用重寫函數處理before_filter

回答

0

我不認爲有一種很好的方法來破解before_filter本身,使其工作。但我認爲這種選擇可能只是做你正在尋找的東西。

試試這個。

class MyController < BaseController 
    before_filter :application_func 

    private 
    def application_func 
     ApplicationController.func 
    end 
end