Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何找到没有对象的方法的源位置?例如,我想查找 Active Record 的 find 方法或 Machinist gem 的 make 方法的源位置。这些方法通常在没有任何对象的情况下被调用。
require 'active_record' m=ActiveRecord::Base.method :find # => #<Method: Class(ActiveRecord::Querying)#find> m.source_location # => ["/<snip>/gems/activerecord-3.2.11/lib/active_record/querying.rb", 4]