我正在實現一個模塊,並通過使用RoR ActiveSupport :: Concern功能將它包括在我的課程中。我在該模塊中使用包含的do .... end塊,但面向「包含的do」行出現「參數數量錯誤(0爲1)」的錯誤。included do ..... end(錯誤的參數錯誤)錯誤
module Icecream
extend ActiveSupport::Concerns
included do #throws error wrong no of arguments(0 for 1))
has_many :flavours
scope :icecreams, ->{where("has_icecreams = ?", true)}
end
.
.
.
.
.
end
包括做甚至需要參數?
它的工作原理沒有參數,請參閱http://api.rubyonrails.org/classes/ActiveSupport/Concern.html(第二代碼塊) – Stefan
的示例Ya Stefan我知道它通常沒有參數,不知道什麼是錯的這個案例。 – Prem
@ArvindMehra它的ActiveSupport ::關注,而不是ActiveSupport ::關注 – nightf0x