Forking a gem for a Rails project

后端 未结 2 836
谎友^
谎友^ 2020-12-07 09:46

I\'ve found myself twice in this situation: I install a gem on my system and start using it from my Rails project. Eventually I need to make some changes to that gem. How sh

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-07 10:24

    Today this is pretty easy to do with Bundler. You make a local copy of the gem and then instead of doing

    gem "whatever"
    

    in your Gemfile, you do:

    gem "whatever", :path => "/home/pupeno/whatever"
    

    After running bundle install, the gem is picked from that directory. Even if you modify something in there, all you need to do to re-load it is restart Rails.

    If you need to deploy an application using your own changes of a Gem, you make a fork, on Github or similar and on the Gemfile you do:

    gem "whatever", :git => "git@github.com:/pupeno/whatever.git"
    

    and that's it. It's simple, straightforward and beautiful.

提交回复
热议问题