Merge pull request #42391 from abhaynikam/document-active-storage-generator-types

Document Active Storage attachment and attachments field generators [ci skip]
This commit is contained in:
Zachary Scott 2021-06-05 07:31:50 +09:00 committed by GitHub
commit df7057657e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 2 deletions

View File

@ -320,7 +320,13 @@ The [`has_one_attached`][] macro sets up a one-to-one mapping between records an
files. Each record can have one file attached to it.
For example, suppose your application has a `User` model. If you want each user to
have an avatar, define the `User` model like this:
have an avatar, run a model generator command as follows:
```ruby
bin/rails generate model User avatar:attachment
```
or define the `User` model like this
```ruby
class User < ApplicationRecord
@ -396,7 +402,13 @@ The [`has_many_attached`][] macro sets up a one-to-many relationship between rec
and files. Each record can have many files attached to it.
For example, suppose your application has a `Message` model. If you want each
message to have many images, define the `Message` model like this:
message to have many images, run a model generator command as follows:
```ruby
bin/rails generate model Message images:attachments
```
or define the `Message` model like this:
```ruby
class Message < ApplicationRecord