Ruby gives programmers some incredibly helpful tools to help debug and understand their code. One of these is tools is the
#source_location method. Defined in the Method class,
#source_location will point you to the file in which a given method is defined.
I have found this helpful in trying to find the source of Rails internal methods, so I can understand how Rails operates on a deeper level:
We get back the location of the file, and even the line number. If you want to get a better understanding of what’s going on behind the scenes, give
#source_location a try.