Discovering and Debugging your Gems using `bundle open`

Let's go the next level and debug your gems using the `bundle open` command.

I am recently learning more about Ruby on Rails and I discovered a useful command on GoRails. It is the bundle open command. This command allows you to open the source code of a gem in your editor.

This is very useful when you want to understand how a gem works or when you want to debug a gem. It is necessary to specify the editor with the EDITOR environment variable. For example, if you use Visual Studio Code, you can run the following command:

cd {your_ruby_project}
EDITOR=code bundle open {gem_name}

This will open the source code of the gem in Visual Studio Code. It has to be one of the gems that you have already installed.

You can directly modify the source code of the gem and see the changes in your Ruby application. I often write puts or binding.irb statements in the gem source code to understand how it works.