Talk Outline
-----------------
Why Active Storage?
How to build a simple rails app to upload image.
Uploading with S3 (External Service).
How to test ?
Performance & Security Considerations
Beyond the Basic
Summary
# Used as the base secret for all MessageVerifiers in Rails, including the one protecting cookies. secret_key_base: 81b8cf7fb4c6a0afc08a20aee3090ebccd8f5ed69859ebdc09dc3b4d8cc7fe98c2b62ea8d4cbee369b45be560f1c59335cfdc4b 84b1a498d6bd08f375d9e528e
spec/controllers/posts_controller_spec.rb describe 'POST #create' do it 'attaches the uploaded file' do file = fixture_file_upload(Rails.root.join('public', 'apple-touch-icon.png'), 'image/png') expect { post :create, params: { post: { image: file } } }.to change(ActiveStorage::Attachment, :count).by(1) end end
app. × Alternative to paperclip gem. × Has support for AWS, Azure and Google Cloud. Support for other can be added. × Can run into performance issues (N+1) queries, but has support to handle it. × Can be tested with rspec. × Integrates with Imagemagick.