2012-12-28 26 views
8

Làm thế nào tôi có thể có một mối quan tâm mà tôi đã viết như thế này:Overloading một phương pháp trong một ActiveSupport :: Lo ngại

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

được bao gồm trong một mô hình quá tải my_concern_magic? Ví dụ.

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

Trả lời

11

Kể từ bao gồm một module chèn nó vào trong chuỗi tổ tiên, bạn chỉ có thể gọi super:

class User 
    include Concerns::MyConcern 

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

Cảm ơn Andrew! Làm việc như người ở. –

Các vấn đề liên quan