从作为引擎安装的 gem 中重载 lib 文件 [英] Overloading lib files from gem mounted as engine
本文介绍了从作为引擎安装的 gem 中重载 lib 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用作为引擎安装的 gem,并且想要自定义一些类.我想重载的文件位于我本地的 rvm 目录
I am using a gem that is mounted as engine and want to customize some classes. The files i want to overload are located in my local rvm dir
(rvmdir)/(gem)/lib/(modulename)/containers/file_to_override.rb
我将文件复制到我的应用程序目录
I copied the file to my app dir
(appdir)/lib/(modulename)/containers/file_to_override.rb
并定制了一些输出.
文件看起来像这样:
module (Modulename)
module Containers
class FileToOverride << xxx
...
end
end
end
但它似乎并没有超载.是否可以在我自己的应用程序中覆盖 lib 文件?
But it does not seem to overload. Is it possible to override lib files in my own application?
推荐答案
如果我把文件放在 /config/initializer/file_to_override.rb
中,上面的内容就可以工作.
If i put the file in /config/initializer/file_to_override.rb
with the above content it works.
这篇关于从作为引擎安装的 gem 中重载 lib 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文