Commit Graph

841 Commits

Author SHA1 Message Date
Jonathan Hefner
07bee949c4 Replace backticks with RDoc markup [ci-skip]
RDoc does not support backticks the way that Markdown does.  Instead,
inline code must be wrapped with `+` or `<tt>`.
2022-02-21 11:11:11 -06:00
Jean Boussier
e26372b713 Implicitly assert no exception is raised in assert_queries & al
Fix: https://github.com/rails/rails/pull/44397
Ref: https://github.com/rails/rails/pull/37313
Ref: https://github.com/rails/rails/pull/42459

This avoid mistakes such as:

```ruby
assert_raise Something do
  assert_queries(1) do
    raise Something
  end
end
```

Co-Authored-By: Alex Coomans <alexc@squareup.com>
2022-02-19 09:11:14 +01:00
Gannon McGibbon
aaa64687e8
Revert #38957 (#44287)
* Revert "Pass service_name param to DirectUploadsController"

This reverts commit 193289dbbe146c56ec16faf8dd1a2c88611feb83.

* Revert "Multi-service direct uploads in Action Text attachment uploads"

This reverts commit 0b69ad4de6ef89c285833a90dd23db25cad7b669.
2022-01-29 14:27:45 +01:00
Abhay Nikam
5c7468dba8 Fixes active storage changelog entry(#44244) formatting [ci skip] 2022-01-28 16:32:56 +05:30
Luke Lau
7e61f808c6 Don't stream redirect controller responses
They don't need to be streamed and by including
ActiveStorage::Streaming, they spin up new threads which can cause
problems with connection pools as detailed in #44242
2022-01-26 12:04:40 +00:00
jlestavel
2197814074
Allow app to opt out of precompiling activestorage js assets (#43967) 2022-01-18 18:19:30 +01:00
weavermedia
bc9060a22a Improve ActiveStorage analyzer error message for missing ffprobe. Add mention to guides. 2022-01-07 10:32:03 -08:00
Nando Vieira
865a01d87c
Export assets. 2022-01-06 13:51:46 -08:00
Nando Vieira
a75cf1f1f0
Export other ActiveStorage JavaScript modules. 2022-01-06 09:24:36 -08:00
Rafael Mendonça França
c97dee313c
Require shellwords where it is used
Ruby 3.1 doesn't require this by default anymore.
2022-01-06 00:19:11 +00:00
Ryuta Kamizono
65766ebcc8 Bump license years to 2022 [ci-skip] 2022-01-01 15:22:15 +09:00
Rafael Mendonça França
a17629e393
Fix image_processing link
[ci skip]
2021-12-29 21:36:51 +00:00
Rafael Mendonça França
dae7e46db4
Remove CHANGELOG entry that is already in 7-0-stable 2021-12-15 00:55:18 +00:00
Sean Doyle
4f191b9754 ActiveStorage: support empty attachments submits
The background
---

Configuration for replacing a collection was introduced in
[rails/rails#36716][].

However, since [rails/rails#42596][] has been merged, Rails 7.1 and
beyond will default to _replacing_ an Active Storage `has_many_attached`
relationship, as opposed to _appending to it_.

The problem
---

With replacement as the established precedent, it's currently a
challenge to replace an existing collection with an empty one.

The solution
---

This commit makes two changes.

The first is to Action View and its form building helpers. The change
draws inspiration from how an `<input type="checkbox">` field (or
collection of fields) is paired with an `<input type="hidden">` field to
represent the unchecked value. The change pairs any `<input type="file"
multiple="multiple">` elements with an `<input type="hidden">` element
to represent an empty collection. Like the [check_box][] form builder
method, the `file_field`  method accepts an `include_hidden:` option to
skip the creation of the hidden element.

The second is to how Active Storage generates attribute assignment
methods through `has_many_attached`. With the possibility of an `<input
type="file">` field being paired with an `<input type="hidden"
value="">` field, the backing models need to be able to coerce an
"empty-ish" value into an empty list. For example:

```ruby
@user.highlights = [""]
@user.highlights        # => []
```

When combined, these changes enable consumer applications to submit
"empty" collections to blank out existing attachments.

Support is configured through the
`config.active_storage.multiple_file_field_include_hidden` configuration
value, which defaults to `false`.

[check_box]: https://edgeapi.rubyonrails.org/classes/ActionView/Helpers/FormBuilder.html#method-i-check_box
[rails/rails#36716]: https://github.com/rails/rails/pull/36716
[rails/rails#42596]: https://github.com/rails/rails/pull/42596
2021-12-14 18:40:35 -05:00
Rafael Mendonça França
8b6342e341
Use if_not_exists instead of table_exists? 2021-12-08 23:25:02 +00:00
Rafael Mendonça França
6172f541d8
Merge pull request #43776 from lifeiscontent/patch-1
Update 20191206030411_create_active_storage_variant_records.rb
2021-12-08 18:24:08 -05:00
Jonathan Hefner
4917ee9df6 Use dynamic Rails version in framework dummy apps
This matches what we currently generate for plugin dummy apps.
2021-12-08 11:31:49 -06:00
Rafael Mendonça França
83d85b2207
Start Rails 7.1 development 2021-12-07 15:52:30 +00:00
Rafael Mendonça França
b37c02e027
✂️ 2021-12-06 22:39:44 +00:00
Rafael Mendonça França
47fc79ca2b
Merge pull request #43637 from alxjrvs/blob-representation-disposition
Fix Rails 7 Regression - ActiveStorage Content Disposition
2021-12-06 17:39:14 -05:00
Rafael Mendonça França
aa55566bcf
Merge pull request #42599 from santib/use-rails-guides-instead-of-edge-guides
Use rails guides instead of edge guides [ci skip]
2021-12-06 17:36:52 -05:00
Aaron Reisman
6ed63abecd
Update 20191206030411_create_active_storage_variant_records.rb
In the cast of bootstrapping a project for the first time without active storage, when running `rails app:update` this migration would result in trying to create the table twice.
2021-12-03 19:55:01 -08:00
Kasper Timm Hansen
1df9b01fe6 Pass an array through our stack, don't bother converting back & forth
Users aren't likely to pass non-array values here anyway.
2021-12-04 02:25:42 +01:00
Kasper Timm Hansen
f34fcac88f [ci skip] compose no longer returns the checksum, remove comment 2021-12-04 02:19:19 +01:00
Kasper Timm Hansen
1c309b6bbd compose is primarily meant to take blobs so make them a positional argument 2021-12-04 02:14:48 +01:00
Kasper Timm Hansen
14f190f337 Flip blob question to allow us to exit early 2021-12-04 01:20:05 +01:00
David Heinemeier Hansson
6c828836c1 Distribute both ESM and CJS version
And make sure module refers to the ESM version.
2021-12-03 11:12:07 +01:00
Jean Boussier
b30148a2e8 Typo in Active Storage: custom_metadatata -> custom_metadata
Introduced in https://github.com/rails/rails/pull/43294
2021-11-30 11:31:52 +01:00
Gannon McGibbon
79a5e0b759 Add ActiveStorage::Blob.compose 2021-11-25 19:37:57 -05:00
Gannon McGibbon
ff6484b355 Fix AzureStorageService#headers_for_direct_upload default for #43294 2021-11-25 14:17:17 -05:00
Gannon McGibbon
896e7477f8 Fix metadata assertions in direct upload tests 2021-11-23 19:00:05 -05:00
Gannon McGibbon
05ec88cdb2
Merge pull request #43294 from joshuamsager/joshuamsager/as-custom-metadata
[ActiveStorage] Custom Metadata
2021-11-23 17:49:59 -05:00
Joshua Sager
e106a4a1d2 Introduce custom metadata 2021-11-23 17:35:33 -05:00
Rafael Mendonça França
b95077afac
Merge pull request #43045 from sandip-mane/array-syntax-consistancy
Makes the array syntax consistent with other use cases
2021-11-19 15:56:42 -07:00
Rafael Mendonça França
1fde031e89 Fix gemspec 2021-11-15 21:06:21 +00:00
Rafael Mendonça França
9195b7fd0a
Require MFA to release rails 2021-11-15 20:37:42 +00:00
Gannon McGibbon
c22734b66b Stub cortrect direct upload service names 2021-11-15 14:15:41 -05:00
DmitryTsepelev
193289dbbe Support direct uploads to multiple services 2021-11-14 11:49:06 +03:00
alxjrvs@gmail.com
acda391b3f Update ActiveStorage Blobs Proxycontroller 2021-11-12 13:08:13 -05:00
alxjrvs@gmail.com
8be05519cd Update ActiveStorage Representation Proxycontroller 2021-11-12 13:08:04 -05:00
Alex Ghiculescu
550d728bd1 Active Storage: incorrect defaults
https://github.com/rails/rails/pull/42225 identified that some of the content types used as defaults by Active Storage aren't recognized by `mini_mime`. This means that in practice code like [this](https://github.com/rails/rails/pull/42225/files#diff-7a3ec24c556b138abdbd67066ab5125b73528e45891d83142e417d3944194128R116) will crash or not function correctly. In [this](https://github.com/rails/rails/pull/42225/files#diff-c2010824d2d2e8d841ff4fc058c264c12d870e893025b153e6de571fba6b6c6cR194) example, a file with content_type `image/jpg` is treated as a PNG by the representer, since `image/jpg` isn't a valid content type according to `mini_mime`.

I don't think the default content_types should include formats that have never actually worked, so I'm proposing we remove them from the defaults.
2021-09-22 16:38:52 -05:00
Rafael Mendonça França
50d60e4f7c
Allow Marcel to be released following semver 2021-09-20 17:19:57 -04:00
Justin Coyne
31780364b7
Add explicit rendering to DiskController#update
This avoids unhelpful messages in the logs:
```
No template found for ActiveStorage::DiskController#update, rendering head :no_content
```
2021-09-17 13:32:28 -05:00
Alex Ghiculescu
5acc32ac54
Generate less initializers in new/upgraded Rails apps (part 2) (#43237) 2021-09-17 09:06:17 +02:00
Rafael Mendonça França
d177551c30
Preparing for 7.0.0.alpha2 release 2021-09-15 18:22:51 -04:00
Rafael Mendonça França
9b7be48212
Preparing for 7.0.0.alpha1 release 2021-09-15 17:55:08 -04:00
Rafael Mendonça França
fd41ea1f2d
Merge branch 'main' into less-initializers 2021-09-15 17:18:49 -04:00
Xavier Noria
89801b2a43 Depend on ruby/debug, replacing Byebug
ruby/debug is a new debugger that is going to ship with CRuby.

It makes sense for Rails to switch to this one because that is
where the language is heading, and because Byebug is not fully
compatible with Zeitwerk. See

    https://github.com/deivid-rodriguez/byebug/issues/564

While ruby/debug has not been heavily tested with Zeitwerk,
casual usage seems to suggest it works without issues, including
explicit namespaces, which is where Byebug and Zeitwerk conflict.

Byebug is terrific, thanks a lot for all these years. ❤️
2021-09-08 17:35:41 +02:00
Jean Boussier
c91c266872 Enable Style/ExplicitBlockArgument cop
This reduce the stack size which is beneficial for
exceptions performance.

See: https://gist.github.com/byroot/cb3bcadcc3701c2518d002fb8d3a4e7a

However the cop is unsafe because it might change the block arity,
so it can run into some false positives.
2021-09-05 17:06:19 +02:00
David Heinemeier Hansson
82e4432058
Javascript generator option with choices (#43160)
* Switch to a single controller option for choosing JavaScript approach

* Remove remnants of webpacker specific work within Rails

* No longer used

* Missing space

* Raise if unknown option is passed

* Style

* Use latest versions

* Make channels setup generic to all node setups

* Make Action Text installer work with any node package manager

* Explaining variables are not useless

* Rubocop pleasing

* Don't rely on Rails.root

Tests don't like it!

* Rubocopping

* Assume importmap

* No longer relevant

* Another cop

* Style

* Correct installation notice

* Add dependencies for action cable when adding a channel

* Fix paths to be relative to generator

* Just go straight to yarn, forget about binstub

* Fix tests

* Fixup installer, only yarn once

* Test generically with run

* Style

* Fix reference and reversibility

* Style

* Fix test

* Test pinning dependencies

* Remove extra space

* Add more tests

* Use latest dependencies

* Relegated this to controllers

* Refactor ChannelGenerator + more tests

Use a uniform level of abstraction
2021-09-04 11:53:57 +02:00