Question : rails get source method
Answered by : puzzled-peacock-nlwdehk8n1mi
class A def foo end
end
file, line = A.instance_method(:foo).source_location
# or
file, line = A.new.method(:foo).source_location
puts "Method foo is defined in #{file}, line #{line}"
# => "Method foo is defined in temp.rb, line 2"
Source : https://stackoverflow.com/questions/3393096/how-can-i-get-source-code-of-a-method-dynamically-and-also-which-file-is-this-me/46966145 | Last Update : Tue, 26 May 20