Show definition of a method at runtime in Ruby
Many people know about
method(:foo).source_location to find where a method is defined at runtime. I just found a better way by using pry.
From the pry console, run:
 pry(main)> show-source Bar.scoped.where From: /Users/arturo/.rvm/gems/ruby-2.2.6/gems/activerecord-18.104.22.168/lib/active_record/relation/query_methods.rb @ line 132: Owner: ActiveRecord::QueryMethods Visibility: public Number of lines: 7 def where(opts, *rest) return self if opts.blank? relation = clone relation.where_values += build_where(opts, rest) relation end