2
只是好奇,为什么发生这种情况在轨控制台:应用程序控制器没有子类?
Loading development environment (Rails 4.1.5)
2.1.2 :001 > require 'application_controller'
=> true
2.1.2 :002 > ApplicationController
=> ApplicationController
2.1.2 :003 > ApplicationController.subclasses
=> []
2.1.2 :004 > ::ApplicationController.descendants
=> []
我有这个控制器
class MyController < ApplicationController
end
所以我很期待ApplicationController.subclasses #=> [MyController]
,但是,我发现了一个空数组:(
这个答案和第一条评论可能会让你感兴趣http://stackoverflow.com/a/1564401/976775 – MrYoshiji 2014-09-26 14:08:21
因为懒加载。 – 2014-09-26 14:10:28
@MrYoshiji:我在生产模式'rails c -e production'中尝试了相同的方法,它返回相同的结果。''[''' – 2014-09-26 14:26:53