Answers for "ruby on rails open source"

1

rails get source method

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"
Posted by: Guest on May-19-2020

Browse Popular Code Answers by Language