rails
https://github.com/rails/rails
Ruby
Ruby on Rails
ActiveStorage::Attached::One#attach
Associates a given attachment with the current record, saving it to the database.
Examples:
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(avatar_blob) # ActiveStorage::Blob objectEdit
git clone [email protected]:rails/rails.git
cd rails
open activestorage/lib/active_storage/attached/one.rb
Contribute
# Make a new branchgit checkout -b -your-name--update-docs-ActiveStorage--Attached--One-attach-for-pr
# Commit to gitgit add activestorage/lib/active_storage/attached/one.rbgit commit -m "better docs for ActiveStorage::Attached::One#attach"
# Open pull requestgem install hub # on a mac you can `brew install hub`
hub fork
git push <your name> -your-name--update-docs-ActiveStorage--Attached--One-attach-for-pr
hub pull-request
# Celebrate!