Ruby on rails 如何阅读Rails API

Ruby on rails 如何阅读Rails API,ruby-on-rails,ruby,ruby-on-rails-3,Ruby On Rails,Ruby,Ruby On Rails 3,我很难理解Rails API。我试图找出一种方法来理解我可以从Rails中的某些点调用什么,比如当我在控制器中时,所以我写了一些东西来告诉我所有可用的方法,这些方法按它们属于哪个模块/类排序: last_sig = "" self.methods.each do |method| #i_am = self.method(method).owner #puts i_am.class #places.push(self.method(method).owner) m

我很难理解Rails API。我试图找出一种方法来理解我可以从Rails中的某些点调用什么,比如当我在控制器中时,所以我写了一些东西来告诉我所有可用的方法,这些方法按它们属于哪个模块/类排序:

last_sig = ""
self.methods.each do |method|
    #i_am = self.method(method).owner
    #puts i_am.class
    #places.push(self.method(method).owner)
    m = self.method(method)
    sig = "#{m.owner.class}: #{m.owner}"
    if sig != last_sig
        last_sig = sig
        puts sig
    end
    puts "    #{method}"
end
作为一个例子,我发现(仅将此作为一个简单的示例)我可以使用render()方法,它位于ActionController::Instrumentation,然后我查看那里的render()函数,它说:

render(*args)
# File actionpack/lib/action_controller/metal/instrumentation.rb, line 38
def render(*args)
  render_output = nil
  self.view_runtime = cleanup_view_runtime do
    Benchmark.ms { render_output = super }
  end
  render_output
end

就是这么说的,我不明白如何从这里我可以理解它是如何工作的,然后我做了更多的搜索,幸运的是我发现它被记录在ActionView中,我想知道我是如何知道这一点的?无论如何,任何关于如何阅读API的提示都将受到欢迎-似乎API中的许多内容都没有为用户记录,我不知道它们是为Rails的用户还是开发人员准备的-我习惯于使用jQuery这样的文档,它似乎更容易通过使用来发现功能-

参见
super
调用?这是给你的提示。实际的呈现发生在继承链的某个位置。另外,
self.class.祖先
可能会有所帮助。这将为您提供一组包含在当前类中的类/模块。你可以在通常的地方查阅他们的文档。