From: Ryan Davis Date: 2012-10-15T16:46:48+09:00 Subject: Re: How to find where a method is defined On Oct 14, 2012, at 22:13 , 前川 享仁 wrote: > I created a file named hello_controller.rb and modifiedits code as bellow: > ------------------------------------------ > class HelloController < ApplicationController > def index > render :text => 'hello world' > end > end > -------------------------------------------- > > In the above I used the method named 'render', butI didn't know where it > was defined. So I modified the program further like this: [...lots of code to replicate how ruby finds methods...] it's a lot easier than that. That's basically what ruby does when it is trying to execute a method. Instead, grab the method you want and ask it: 10001 % ruby19 -S irb >> class X; def x; end; end >> class Y < X; def y; p method(:x).source_location; end; end >> Y.new.y ["(irb)", 1] Not the best example, of course, but you get the idea.