Skip to content

Commit 439e8be

Browse files
authored
Merge pull request rails#50217 from fastjames/document_variant_preprocessed_option
Document the `preprocessed` variant option [ci skip]
2 parents 06d9c3c + 87c614a commit 439e8be

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

guides/source/active_storage_overview.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,19 @@ end
462462
<%= image_tag user.video.preview(:thumb) %>
463463
```
464464

465+
If you know in advance that your variants will be accessed, you can specify that
466+
rails should generate them ahead of time:
467+
468+
```ruby
469+
class User < ApplicationRecord
470+
has_one_attached :video do |attachable|
471+
attachable.variant :thumb, resize_to_limit: [100, 100], preprocessed: true
472+
end
473+
end
474+
```
475+
476+
Rails will enqueue a job to generate the variant after the attachment is attached to the record.
477+
465478
[`has_one_attached`]: https://api.rubyonrails.org/classes/ActiveStorage/Attached/Model.html#method-i-has_one_attached
466479
[Attached::One#attach]: https://api.rubyonrails.org/classes/ActiveStorage/Attached/One.html#method-i-attach
467480
[Attached::One#attached?]: https://api.rubyonrails.org/classes/ActiveStorage/Attached/One.html#method-i-attached-3F

0 commit comments

Comments
 (0)