How to read library codes 【Ruby on Rails】
We sometimes have to read library codes for curiosity or bug fixes. However, there are some techniques needed, so I’ll write them down here.
Set up path for installing gems
bundle config set path ‘vendor/bundle’ —- local
Codes of library become visible in our projects and it has become possible to insert pry codes into libraries.
Find where methods are defined
=> ['book.rb', 2]
Find a caller
class BooksController < ApplicationController
# caller is default in Ruby
・backtrace(this is in byebug)
That’s all! Make debugging more effective by using techniques above.