Gem Viking for Rails Project

I found myself twice in this situation: I install the gem in my system and start using it from my Rails project. In the end, I need to make some changes to this stone. How do I proceed?

Ideally, I would like to check the source code of this gem somewhere, for example ~ / third_party / gems, work on it, and use the Rails project instead. Is it possible?

In all cases, the gems were on github, so I could probably use it on github, clone it, make my chances and maintain my own branch. I suppose then I would install this branch directly with gem installed on my server. It makes sense?

+52
ruby ruby-on-rails fork gem
Oct 17 '09 at 17:27
source share
2 answers

This is pretty easy today with the Bundler. You create a local copy of the gem, and then instead

gem "whatever" 

in your gemfile, you:

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

After starting the installation of the package, pearls are selected from this catalog. Even if you change something, all you need to do to reload is restart Rails.

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

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

and what is he. It is simple, direct and beautiful.

+90
Oct 01 2018-10-10 at
source share

In all cases, the gems were on github, so I could probably use it on github, clone it, make my chances and maintain my own branch. I suppose then I would install this branch directly with gem installed on my server.

If you really need to hack a real source of gems, then yes, this will be the way to do it. However, this should be a last resort. You do not want to maintain the actual gem if you do not need it. Why not extend the classes from the source of the gems whose functionality you need to change and use your classes instead of the gem classes in your Rails code?

It rarely happens that you really need to crack third-party code in order to do what you need. Good software can be expanded / easily supplemented.

+5
Oct 17 '09 at 17:58
source share