Reputation: 47106
I have a scenario where I need to modify certain functions within my plugin. So I thought I can change the files within the vendor/plugins/
folder. But then I realized that my installed gems code has been used by rails instead of vendor/plugins/
. I thought of removing the gem from my gemlist
but that throws an error. So how can I redirect my rails to use the plugins within vendor/plugins/
folder instead of my gems?
Upvotes: 0
Views: 295
Reputation: 3091
Try monkey patching instead of modifying plugins/gems directly. I monkey patch them in the lib/ folder and config.auto_load it in my environment. It's not too bad, just make sure it's in the same modules, and has the same method name. For instance, to override a string method, you could do something like:
class String
def method_to_override
do_something
super # if you want to still use the original method
end
end
I recommend trying to stay away from directly modifying anything directly.
Also, if I'm using bundled gems, I usually bundle exec command, but I think that still loads the gems out of the path I chose. I have rarely used plugins as of late.
Upvotes: 0
Reputation: 16629
Try, per the bundler doc:
gem [gem name], :path => [path]
Ex:
gem "rails", :path => "vendor/rails"
Upvotes: 3