未验证 提交 2e84839a 编写于 作者: R Rafael França 提交者: GitHub

Merge pull request #31971 from ydakuka/patch-1

Change structure in the AS core extensions guide [ci skip]
......@@ -925,6 +925,15 @@ The macros `cattr_reader`, `cattr_writer`, and `cattr_accessor` are analogous to
```ruby
class MysqlAdapter < AbstractAdapter
# Generates class methods to access @@emulate_booleans.
cattr_accessor :emulate_booleans
end
```
Also, you can pass a block to `cattr_*` to set up the attribute with a default value:
```ruby
class MysqlAdapter < AbstractAdapter
# Generates class methods to access @@emulate_booleans with default value of true.
cattr_accessor :emulate_booleans, default: true
end
```
......@@ -941,15 +950,6 @@ end
we can access `field_error_proc` in views.
Also, you can pass a block to `cattr_*` to set up the attribute with a default value:
```ruby
class MysqlAdapter < AbstractAdapter
# Generates class methods to access @@emulate_booleans with default value of true.
cattr_accessor :emulate_booleans, default: true
end
```
The generation of the reader instance method can be prevented by setting `:instance_reader` to `false` and the generation of the writer instance method can be prevented by setting `:instance_writer` to `false`. Generation of both methods can be prevented by setting `:instance_accessor` to `false`. In all cases, the value must be exactly `false` and not any false value.
```ruby
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册