Overloading lib files from gem mounted as engine

2020-07-26 11:25发布

问题:

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 

and customized some output.

The file Looks similar to this:

module (Modulename)
  module Containers
    class FileToOverride << xxx
    ...
    end
  end
end

But it does not seem to overload. Is it possible to override lib files in my own application?

回答1:

If i put the file in /config/initializer/file_to_override.rb with the above content it works.