Hacker News new | ask | show | jobs
by inopinatus 3520 days ago
re.2, to find where a function was defined, use source_location on the Method instance. e.g. I have this in a dev-specific initializer:

    class Method
      def subl
        system("subl", source_location.join(":"))
      end
    end
Now if "response.context" is throwing an exception, I can find its definition with

    response.method(:context).subl
Et voila, the source file is opened in Sublime Text and positioned at 'def context'. This even works for the nutty stuff, like methods defined dynamically in an eigenclass.

Also, pry & better_errors are your friends.