Rails 来自 rails 控制台的文档

Rails documentation from rails console

我可以通过这种方式在 API 文档中搜索 rails 控制台中的方法吗?例如。方法参数、返回对象等

不是rails控制台,而是"ri"控制台。这就是我要找的。

从 irb(它也可能在 rails 控制台中工作),你可以做

require 'pry'
pry
require 'pry-doc'
? File.link # Shows documentation for File.link method, replace 
# with whatever method you want

From: file.c (C Method):
Owner: #<Class:File>
Visibility: public
Signature: link(arg1, arg2)
Number of lines: 20

Creates a new name for an existing file using a hard link. Will not
overwrite new_name if it already exists (raising a subclass
of SystemCallError). Not available on all platforms.

   File.link("testfile", ".testfile")   #=> 0
   IO.readlines(".testfile")[0]         #=> "This is line one\n"

static VALUE
rb_file_s_link(VALUE klass, VALUE from, VALUE to)
{
    FilePathValue(from);
    FilePathValue(to);
    from = rb_str_encode_ospath(from);
    to = rb_str_encode_ospath(to);

    if (link(StringValueCStr(from), StringValueCStr(to)) < 0) {
    sys_fail2(from, to);
    }
    return INT2FIX(0);
}

请注意,您需要撬动和 pry-doc 安装:

gem install pry
gem install pry-doc