Running code after Rails is done loading?

*爱你&永不变心* 提交于 2019-12-04 02:35:10

Regarding http://guides.rubyonrails.org/initialization.html, sorry, we're working hard to rewrite it. For your problem, I would try with config.after_initialize in your application.rb

def after_initialize(&block)
  ActiveSupport.on_load(:after_initialize, :yield => true, &block)
end

You have two options really

1) add it into initializers directory and this should be ok.

2) add it at the very end of application.rb, this is less clean but it will have things like initializers ready at this point ;p so if 1) fails because of AR problems do 2)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!