2012-12-28 35 views
8

我怎麼能有,我已經寫了這樣的擔憂:被包含在重載my_concern_magic模型重載的方法在的ActiveSupport ::關注

module Concerns 
    module MyConcern 
    extend ActiveSupport::Concern 
    ... 
    def my_concern_magic(arg0,arg1) 
     #exciting stuff here 
    end 
    end 
end 

?例如。

class User 
    include Concerns::MyConcern 
    ... 
    def my_concern_magic(arg0) 
    arg1 = [1,2,3] 
    my_concern_magic(arg0,arg1) 
    end 
end 

回答

11

由於包括一個模塊將其插入祖先鏈,你可以叫super

class User 
    include Concerns::MyConcern 

    def my_concern_magic(arg0) 
    arg1 = [1, 2, 3] 
    super(arg0, arg1) 
    end 
end 
+0

感謝安德魯!像魅力一樣工作。 –