Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I browse the source code for a gem in Rails3 with RVM (linux & gedit)

I am running rails3 in Ubuntu and using gedit for coding. I am using RVM. To look at the gem source code I tried: bundle open jquery-rails

That doesn't work since I hadn't setup an editor. After setting gedit as the editor it still doesn't work because gedit can't be passed directories. I guess it only works with files. Too bad :(.

nathan.f77's answer to this question ( Lookup Gem or Plugin code packaged in a Rails3 application ) seems promising, but I wasn't able to follow his instructions. They lacked sufficient detail for me.

What is a very easy way to browse the source files for gems that I am using in my rails3 app?

like image 801
snowguy Avatar asked Dec 08 '22 22:12

snowguy


2 Answers

bundle show jquery-rails should tell you where the gem source lives on your filesystem. Then open the file that you want.

like image 145
CubaLibre Avatar answered Dec 11 '22 12:12

CubaLibre


CubaLibre's response got me half-way there. The other piece of the puzzle I was able to get from Ask Ubuntu.

Here are the steps to browse gem code in gedit using Ubuntu.

a. From the command line run:

gnome-open $(bundle show [gem-name])

b. This will open up the gem directory in nautilus. From there just double click on file you'd like to see and it will open up in gedit.

like image 25
snowguy Avatar answered Dec 11 '22 12:12

snowguy