1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activestorage/app/models/active_storage
Alex Ghiculescu bd33ddaf71 Active Storage: Blob creation shouldn't crash if no service selected
https://github.com/rails/rails/issues/41653 noted an issue where if there's service configured (`config.active_storage.service` is commented out), Blob creation via direct upload crashes:

```
Started POST "/rails/active_storage/direct_uploads" for ::1 at 2021-03-09 13:02:57 -0800
Processing by ActiveStorage::DirectUploadsController#create as JSON
  Parameters: {"blob"=>{"filename"=>"banana.jpg", "content_type"=>"image/jpeg", "byte_size"=>577085, "checksum"=>"W/vo/JqBNmJHMCaL+PRlBQ=="}, "direct_upload"=>{"blob"=>{"filename"=>"banana.jpg", "content_type"=>"image/jpeg", "byte_size"=>577085, "checksum"=>"W/vo/JqBNmJHMCaL+PRlBQ=="}}}
Completed 500 Internal Server Error in 12ms (ActiveRecord: 3.3ms | Allocations: 5864)

NoMethodError (undefined method `name' for nil:NilClass):

activestorage (6.1.3) app/models/active_storage/blob.rb:52:in `block in <class:Blob>'
activesupport (6.1.3) lib/active_support/callbacks.rb:427:in `instance_exec'
```

This PR fixes that crash. Blob creation will still fail, but with a more informative error about a `service_name` being required.
2021-03-12 15:12:11 -05:00
..
blob Add requires for mimemagic 2020-09-25 15:00:04 -04:00
attachment.rb Merge branch 'main' into active_storage-named-variants 2021-01-29 03:25:37 +01:00
blob.rb Active Storage: Blob creation shouldn't crash if no service selected 2021-03-12 15:12:11 -05:00
current.rb Use a current model to provide the host for service urls 2018-04-06 20:07:52 +01:00
filename.rb Encode Content-Disposition filenames on send_data and send_file 2018-09-13 21:38:46 +09:00
preview.rb Active Storage: allow serving files by proxying 2020-05-11 16:21:58 -04:00
record.rb Extract ActiveStorage::Record 2020-09-29 11:59:14 -04:00
variant.rb Remove unused require 2020-09-23 14:39:52 -04:00
variant_record.rb Extract ActiveStorage::Record 2020-09-29 11:59:14 -04:00
variant_with_record.rb Set default variant format from blob content type 2020-09-22 13:03:53 -04:00
variation.rb Remove deprecated ActiveStorage::Transformers::MiniMagickTransformer 2020-10-30 00:25:47 +00:00