代码:
class User
include ModuleA
include ModuleB
end
module ModuleA
extend ActiveSupport::Concern
included do
def hi
end
end
end
module ModuleB
extend ActiveSupport::Concern
def hi(param)
end
def say_hi
hi(param)
end
end
的错误
ArgumentError: wrong number of arguments (1 for 0)
# ./app/models/concerns/modulea.rb:16:in `hi'
Rails 4
答案 0 :(得分:3)
正确的答案是删除两个模块中包含的内容。 在没有包含块的情况下,将很好地包含实例方法。正如@Sergio Tulentsev所建议的
class User
include ModuleA
include ModuleB
end
module ModuleA
extend ActiveSupport::Concern
def hi
end
end
module ModuleB
extend ActiveSupport::Concern
def hi(param)
end
def say_hi
hi(param)
end
end