Fab Fab - 1 year ago 56
Ruby Question

How can I see the source code of a gem installed on my machine?

I installed Devise in my Rails app and I want to read through the source code and learn how it works. I looked through the entire folder structure of my Rails app, but couldn't find any code (except for the method calls).

I know I can see the source from the Github repository but I would like to see it in my editor and on my local machine.

I'm guessing this code must be in some main Ruby directory, but I'm having trouble locating it. Any help is appreciated. Thanks.

Answer Source

Try gem unpack, it will copy source of a gem to current directory. For example,

gem unpack rails

Documentation: gem unpack.