2013-10-14 15 views
4

我正在實現一個模塊,並通過使用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 

包括做甚至需要參數?

+0

它的工作原理沒有參數,請參閱http://api.rubyonrails.org/classes/ActiveSupport/Concern.html(第二代碼塊) – Stefan

+0

的示例Ya Stefan我知道它通常沒有參數,不知道什麼是錯的這個案例。 – Prem

+3

@ArvindMehra它的ActiveSupport ::關注,而不是ActiveSupport ::關注 – nightf0x

回答

9

哦....得到它固定...

愚蠢的錯誤,錯字

延長的ActiveSupport :: 關注應該關注

+2

從一個巨大的未來頭痛挽救了我。感謝您發佈解決方案! – mlkmt

7

你可以有,如果你同樣的問題做include ActiveSupport::Concern而不是extend ActiveSupport::Concern