How to extend a class from an initializer and have it reload in development environment?

前端 未结 5 1917
感动是毒
感动是毒 2021-02-08 00:03

I am extending a class (which is in a plugin) by including a module, this is done in an initializer.

require \'qwerty/core/user\'
User.send :include, Qwerty::Co         


        
5条回答
  •  暖寄归人
    2021-02-08 00:49

    In Rails 3.x you can configure a block to run every time reloads happen (in development mode, or when config.cache_classes = false). This would go in an initializer:

    ActionDispatch::Callbacks.to_prepare do
        # configure stuff or initialize
    end
    

提交回复
热议问题