> For the complete documentation index, see [llms.txt](https://kelby.gitbook.io/rails-beginner-s-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kelby.gitbook.io/rails-beginner-s-guide/actioncontroller/outside_the_metal/metal_helpers.md).

# Helpers

```
helpers
```

本质是 ActionView::Base 的实例对象：

```ruby
ApplicationController.helpers.class
# => ActionView::Base
```

rails 控制台里的 `helper` 方法指的就是它。

除上述方法外，还有：

```
all_helpers_from_path

helper_attr

modules_for_helpers
```

`helper_attr` 用到了 AbstractController::Helpers 里的 helper\_method 方法。

另外，有配置：

```ruby
# 默认为 true
config.action_controller.include_all_helpers = false
```

可以设置单个 Controller 只加载和它名字对应的 Helper 模块，而不是所有的 Helper(所有的 helper 方法)。

除上述描述外，因为它 `include AbstractController::Helpers` 所以它还有两个比较重要的方法可用。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://kelby.gitbook.io/rails-beginner-s-guide/actioncontroller/outside_the_metal/metal_helpers.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
