Commit Graph

14 Commits

Author SHA1 Message Date
Jonathan del Strother
54d3934d43
Fix JSON-encoding ActiveStorage::Filename
ActiveStorage::Filename was missing quotes when encoded,
generating invalid json like this -

```
JSON.generate(foo: ActiveStorage::Filename.new("bar.pdf") # => '{"foo":bar.pdf}'
```

Delete to_json and rely on the implementation from ActiveSupport::ToJsonWithActiveSupportEncoder
2024-02-06 12:37:58 +00:00
Petrik
0e7cb8d327 Add missing headers to Active Storage docs [ci-skip] 2023-04-03 12:29:49 +02:00
Fumiaki MATSUSHIMA
890485cfce Encode Content-Disposition filenames on send_data and send_file 2018-09-13 21:38:46 +09:00
Eugene Kenny
1e55ee5a28 Use require_dependency inside Active Storage
Active Storage is an engine which means its models, jobs and controllers
are autoloaded by Rails rather than Ruby. Unfortunately this means it's
subject to the same gotchas as applications, including this one:

http://guides.rubyonrails.org/v5.1.4/autoloading_and_reloading_constants.html#when-constants-aren-t-missed-qualified-references

On Ruby < 2.5, constants nested under classes can't be autoloaded by
Rails if a top level constant already exists with the same name.

To avoid clashing with constants defined in users' applications or gems,
we can use `require_dependency` to ensure that the nested constants are
loaded before they're used.
2018-02-14 23:15:12 +00:00
Jason Lee
0625a2ba80 Fix blob.service_url for supports string or nil :filename option.
- Make sure `blob.service_url` present a `ActiveStorage::Filename` type to `serivce.url`.
- Add `ActiveStorage::Filename.wrap` method.

before:

```rb
blob.service_url(filename: ActiveStorage::Filename.new("new.txt"))

blob.service_url(filename: "new.txt")
=> NoMethodError: undefined method `parameters' for "new.txt":String

params = {}
blob.service_url(filename: params[:filename])
=> NoMethodError: undefined method `parameters' for nil:NilClass
```

after:

```rb
blob.service_url(filename: "new.txt")
blob.service_url(filename: nil)
```
2018-02-08 10:15:55 +08:00
George Claghorn
74c4017daf Exclude ActiveStorage::Filename{#parameters,::Parameters} from API docs [ci skip] 2017-12-13 08:34:49 -05:00
George Claghorn
4e68525e33 Add missing word [ci skip] 2017-09-20 15:35:01 -04:00
George Claghorn
91edf754c4 Flesh out ActiveStorage::Filename docs 2017-09-20 15:34:04 -04:00
Yoshiyuki Hirano
e38900b845 Update Active Storage docs [ci skip] 2017-08-30 02:40:03 +09:00
Yoshiyuki Hirano
0196ac6654 Enable links in Active Storage docs [ci skip] 2017-08-26 05:47:26 +09:00
George Claghorn
63395aba5a Encode Content-Disposition filenames according to RFC 2231
Closes #30134.
2017-08-21 18:23:15 -04:00
George Claghorn
8bd14971b9 Rename ActiveStorage::Filename#extname to extension_with_delimiter 2017-08-20 16:30:15 -04:00
Koichi ITO
d02844f249 Use frozen string literal in Active Storage 2017-08-12 21:43:42 +09:00
Rafael Mendonça França
9330d01ada Add 'activestorage/' from commit '3f4a7218a4a4923a0e7ce1b2eb0d2888ce30da58'
git-subtree-dir: activestorage
git-subtree-mainline: 0d58e7e478e79c2d6b2a39a4444d2a17a903b2a6
git-subtree-split: 3f4a7218a4a4923a0e7ce1b2eb0d2888ce30da58
2017-07-31 15:21:22 -04:00