2013-10-22 80 views

回答

4

倘若你的類在模塊內部定義(命名空間,例如),該::在類的開頭定義告訴Rails在底層尋找模塊(沒有命名空間)。作爲一個更具體的例子,如果你有定義爲類如下:

module Foo 
    class MyController < Refinery::AdminController 
    end 
end 

Rails會嘗試將富模塊中找到Refinery::AdminController。但是,如果你在這個格式定義你的類:

module Foo 
    class MyController < ::Refinery::AdminController 
    end 
end 

Rails會只認準Refinery::AdminController僅在基準水平,而不是內Foo

相關問題