mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #30626 from yhirano55/fix_activestorage_readme
Fix file missing in activestorage's example code [ci skip]
This commit is contained in:
commit
fefc5e8e37
3 changed files with 3 additions and 3 deletions
|
@ -24,7 +24,7 @@ class User < ApplicationRecord
|
|||
end
|
||||
|
||||
# Attach an avatar to the user.
|
||||
user.avatar.attach(io: File.open("~/face.jpg"), filename: "avatar.jpg", content_type: "image/jpg")
|
||||
user.avatar.attach(io: File.open("/path/to/face.jpg"), filename: "face.jpg", content_type: "image/jpg")
|
||||
|
||||
# Does the user have an avatar?
|
||||
user.avatar.attached? # => true
|
||||
|
|
|
@ -17,7 +17,7 @@ module ActiveStorage
|
|||
#
|
||||
# document.images.attach(params[:images]) # Array of ActionDispatch::Http::UploadedFile objects
|
||||
# document.images.attach(params[:signed_blob_id]) # Signed reference to blob from direct upload
|
||||
# document.images.attach(io: File.open("~/racecar.jpg"), filename: "racecar.jpg", content_type: "image/jpg")
|
||||
# document.images.attach(io: File.open("/path/to/racecar.jpg"), filename: "racecar.jpg", content_type: "image/jpg")
|
||||
# document.images.attach([ first_blob, second_blob ])
|
||||
def attach(*attachables)
|
||||
attachables.flatten.collect do |attachable|
|
||||
|
|
|
@ -18,7 +18,7 @@ module ActiveStorage
|
|||
#
|
||||
# person.avatar.attach(params[:avatar]) # ActionDispatch::Http::UploadedFile object
|
||||
# person.avatar.attach(params[:signed_blob_id]) # Signed reference to blob from direct upload
|
||||
# person.avatar.attach(io: File.open("~/face.jpg"), filename: "face.jpg", content_type: "image/jpg")
|
||||
# person.avatar.attach(io: File.open("/path/to/face.jpg"), filename: "face.jpg", content_type: "image/jpg")
|
||||
# person.avatar.attach(avatar_blob) # ActiveStorage::Blob object
|
||||
def attach(attachable)
|
||||
if attached? && dependent == :purge_later
|
||||
|
|
Loading…
Reference in a new issue