rails/activestorage/app
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
..
assets/javascripts Add gitattributes for vendored and generated files [ci-skip] 2020-10-04 16:44:37 -05:00
controllers Extract ActiveStorage::Streaming so your own controllers can use it (#41440) 2021-02-19 15:40:56 +01:00
javascript/activestorage Defaults content_type to application/octet-stream 2020-01-07 10:30:56 -08:00
jobs/active_storage Discard ActiveStorage::AnalyzeJobs on ActiveRecord::RecordNotFound 2019-09-28 10:28:21 -04:00
models/active_storage Active Storage: Blob creation shouldn't crash if no service selected 2021-03-12 15:12:11 -05:00