activestorage 7.0.8.6 → 7.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of activestorage might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '081e67136972e6a3b205bac0beff965c632d3d2f956adaaa10c94ce473224bd2'
4
- data.tar.gz: cc4ce99ff4f7437e98d9cbbed2a48d7007cd4553e8c7558cbbf3ce79aaf15481
3
+ metadata.gz: da49aa47055520b04928ebc44c40602bafba1df5f9d6dfa589dc6ac34e6a9f0c
4
+ data.tar.gz: b8a00c49cf73ac4309f4654974ab21497ca97cdf845097a872c878f7dc3dfb6a
5
5
  SHA512:
6
- metadata.gz: e733f1df52d9b02de9c50f26265b62578e4b55832244ccddfd738c6f79b2593dfa66358de87d588f9dd79e394b758945ffa2aa4bfb3f6643edf61d5de9d7f5bc
7
- data.tar.gz: d0542ba9bf7bbc078686a60ada01b6818b70dd5b6e897f4c9aab3c35450c4a653aa299bf8795d18c578c7bece8b039fcf06e97fb423af33f644fa8f228e757cb
6
+ metadata.gz: d1e840853a1250ebab5a2d19faef9a2f5afaebdfcaf99b15f0f6b3a5c7ec3ea3ac527e072fb800ae2f6559e7edd6aa128ba69acb08e25d86afb523a080c64ba3
7
+ data.tar.gz: 8e6a839987b91f76cce8d1630e0690d574bbb0cc752c211a24206c596fe9bee443907727abb314f34ce692b8af291cc669919034c9aad8915bf6f48e81c8ac85
data/CHANGELOG.md CHANGED
@@ -1,3 +1,43 @@
1
+ ## Rails 7.0.10 (October 28, 2025) ##
2
+
3
+ * No changes.
4
+
5
+
6
+ ## Rails 7.0.9 (October 28, 2025) ##
7
+
8
+ * Fix `ActiveStorage::Representations::ProxyController` not returning the proper
9
+ preview image variant for previewable files.
10
+
11
+ *Chedli Bourguiba*
12
+
13
+ * Make untracked variants obey `config.active_storage.content_types_to_serve_as_binary`
14
+ and `config.active_storage.content_types_allowed_inline`.
15
+
16
+ *Chedli Bourguiba* and *Jonathan Hefner*
17
+
18
+ * Fix direct upload forms when submit button contains nested elements.
19
+
20
+ *Marc Köhlbrugge*
21
+
22
+ * Prevent `ActiveRecord::StrictLoadingViolationError` when strict loading is
23
+ enabled and the variant of an Active Storage preview has already been
24
+ processed (for example, by calling `ActiveStorage::Preview#url`).
25
+
26
+ *Jonathan Hefner*
27
+
28
+ * Fix variants not included when eager loading multiple records containing a single attachment
29
+
30
+ When using the `with_attached_#{name}` scope for a `has_one_attached` relation,
31
+ attachment variants were not eagerly loaded.
32
+
33
+ *Russell Porter*
34
+
35
+
36
+ ## Rails 7.0.8.7 (December 10, 2024) ##
37
+
38
+ * No changes.
39
+
40
+
1
41
  ## Rails 7.0.8.6 (October 23, 2024) ##
2
42
 
3
43
  * No changes.
data/README.md CHANGED
@@ -145,7 +145,7 @@ Active Storage, with its included JavaScript library, supports uploading directl
145
145
  1. Include the Active Storage JavaScript in your application's JavaScript bundle or reference it directly.
146
146
 
147
147
  Requiring directly without bundling through the asset pipeline in the application html with autostart:
148
- ```html
148
+ ```erb
149
149
  <%= javascript_include_tag "activestorage" %>
150
150
  ```
151
151
  Requiring via importmap-rails without bundling through the asset pipeline in the application html without autostart as ESM:
@@ -767,9 +767,9 @@ function start() {
767
767
  }
768
768
 
769
769
  function didClick(event) {
770
- const {target: target} = event;
771
- if ((target.tagName == "INPUT" || target.tagName == "BUTTON") && target.type == "submit" && target.form) {
772
- submitButtonsByForm.set(target.form, target);
770
+ const button = event.target.closest("button, input");
771
+ if (button && button.type === "submit" && button.form) {
772
+ submitButtonsByForm.set(button.form, button);
773
773
  }
774
774
  }
775
775
 
@@ -750,9 +750,9 @@
750
750
  }
751
751
  }
752
752
  function didClick(event) {
753
- const {target: target} = event;
754
- if ((target.tagName == "INPUT" || target.tagName == "BUTTON") && target.type == "submit" && target.form) {
755
- submitButtonsByForm.set(target.form, target);
753
+ const button = event.target.closest("button, input");
754
+ if (button && button.type === "submit" && button.form) {
755
+ submitButtonsByForm.set(button.form, button);
756
756
  }
757
757
  }
758
758
  function didSubmitForm(event) {
@@ -12,7 +12,7 @@ class ActiveStorage::Representations::ProxyController < ActiveStorage::Represent
12
12
 
13
13
  def show
14
14
  http_cache_forever public: true do
15
- send_blob_stream @representation.image, disposition: params[:disposition]
15
+ send_blob_stream @representation, disposition: params[:disposition]
16
16
  end
17
17
  end
18
18
  end
@@ -15,9 +15,9 @@ export function start() {
15
15
  }
16
16
 
17
17
  function didClick(event) {
18
- const { target } = event
19
- if ((target.tagName == "INPUT" || target.tagName == "BUTTON") && target.type == "submit" && target.form) {
20
- submitButtonsByForm.set(target.form, target)
18
+ const button = event.target.closest("button, input")
19
+ if (button && button.type === "submit" && button.form) {
20
+ submitButtonsByForm.set(button.form, button)
21
21
  }
22
22
  }
23
23
 
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveStorage::Blob::Servable # :nodoc:
4
+ def content_type_for_serving
5
+ forcibly_serve_as_binary? ? ActiveStorage.binary_content_type : content_type
6
+ end
7
+
8
+ def forced_disposition_for_serving
9
+ if forcibly_serve_as_binary? || !allowed_inline?
10
+ :attachment
11
+ end
12
+ end
13
+
14
+ private
15
+ def forcibly_serve_as_binary?
16
+ ActiveStorage.content_types_to_serve_as_binary.include?(content_type)
17
+ end
18
+
19
+ def allowed_inline?
20
+ ActiveStorage.content_types_allowed_inline.include?(content_type)
21
+ end
22
+ end
@@ -33,6 +33,7 @@ class ActiveStorage::Blob < ActiveStorage::Record
33
33
  include ActiveStorage::Blob::Analyzable
34
34
  include ActiveStorage::Blob::Identifiable
35
35
  include ActiveStorage::Blob::Representable
36
+ include ActiveStorage::Blob::Servable
36
37
 
37
38
  self.table_name = "active_storage_blobs"
38
39
 
@@ -141,7 +142,10 @@ class ActiveStorage::Blob < ActiveStorage::Record
141
142
 
142
143
  def scope_for_strict_loading # :nodoc:
143
144
  if strict_loading_by_default? && ActiveStorage.track_variants
144
- includes(variant_records: { image_attachment: :blob }, preview_image_attachment: :blob)
145
+ includes(
146
+ variant_records: { image_attachment: :blob },
147
+ preview_image_attachment: { blob: { variant_records: { image_attachment: :blob } } }
148
+ )
145
149
  else
146
150
  all
147
151
  end
@@ -229,16 +233,6 @@ class ActiveStorage::Blob < ActiveStorage::Record
229
233
  service.headers_for_direct_upload key, filename: filename, content_type: content_type, content_length: byte_size, checksum: checksum, custom_metadata: custom_metadata
230
234
  end
231
235
 
232
- def content_type_for_serving # :nodoc:
233
- forcibly_serve_as_binary? ? ActiveStorage.binary_content_type : content_type
234
- end
235
-
236
- def forced_disposition_for_serving # :nodoc:
237
- if forcibly_serve_as_binary? || !allowed_inline?
238
- :attachment
239
- end
240
- end
241
-
242
236
 
243
237
  # Uploads the +io+ to the service on the +key+ for this blob. Blobs are intended to be immutable, so you shouldn't be
244
238
  # using this method after a file has already been uploaded to fit with a blob. If you want to create a derivative blob,
@@ -380,14 +374,6 @@ class ActiveStorage::Blob < ActiveStorage::Record
380
374
  Marcel::MimeType.for io, name: filename.to_s, declared_type: content_type
381
375
  end
382
376
 
383
- def forcibly_serve_as_binary?
384
- ActiveStorage.content_types_to_serve_as_binary.include?(content_type)
385
- end
386
-
387
- def allowed_inline?
388
- ActiveStorage.content_types_allowed_inline.include?(content_type)
389
- end
390
-
391
377
  def web_image?
392
378
  ActiveStorage.web_image_content_types.include?(content_type)
393
379
  end
@@ -29,15 +29,19 @@
29
29
  # These libraries are not provided by Rails. You must install them yourself to use the built-in previewers. Before you
30
30
  # install and use third-party software, make sure you understand the licensing implications of doing so.
31
31
  class ActiveStorage::Preview
32
+ include ActiveStorage::Blob::Servable
33
+
32
34
  class UnprocessedError < StandardError; end
33
35
 
36
+ delegate :filename, :content_type, to: :variant
37
+
34
38
  attr_reader :blob, :variation
35
39
 
36
40
  def initialize(blob, variation_or_variation_key)
37
41
  @blob, @variation = blob, ActiveStorage::Variation.wrap(variation_or_variation_key)
38
42
  end
39
43
 
40
- # Processes the preview if it has not been processed yet. Returns the receiving Preview instance for convenience:
44
+ # Processes the preview if it has not been processed yet. Returns the receiving +ActiveStorage::Preview+ instance for convenience:
41
45
  #
42
46
  # blob.preview(resize_to_limit: [100, 100]).processed.url
43
47
  #
@@ -51,6 +51,8 @@
51
51
  # * {ImageProcessing::Vips}[https://github.com/janko/image_processing/blob/master/doc/vips.md#methods]
52
52
  # * {ruby-vips reference}[http://www.rubydoc.info/gems/ruby-vips/Vips/Image]
53
53
  class ActiveStorage::Variant
54
+ include ActiveStorage::Blob::Servable
55
+
54
56
  attr_reader :blob, :variation
55
57
  delegate :service, to: :blob
56
58
  delegate :content_type, to: :variation
@@ -89,12 +91,6 @@ class ActiveStorage::Variant
89
91
  ActiveStorage::Filename.new "#{blob.filename.base}.#{variation.format.downcase}"
90
92
  end
91
93
 
92
- alias_method :content_type_for_serving, :content_type
93
-
94
- def forced_disposition_for_serving # :nodoc:
95
- nil
96
- end
97
-
98
94
  # Returns the receiving variant. Allows ActiveStorage::Variant and ActiveStorage::Preview instances to be used interchangeably.
99
95
  def image
100
96
  self
@@ -3,8 +3,11 @@
3
3
  # Like an ActiveStorage::Variant, but keeps detail about the variant in the database as an
4
4
  # ActiveStorage::VariantRecord. This is only used if +ActiveStorage.track_variants+ is enabled.
5
5
  class ActiveStorage::VariantWithRecord
6
+ include ActiveStorage::Blob::Servable
7
+
6
8
  attr_reader :blob, :variation
7
9
  delegate :service, to: :blob
10
+ delegate :content_type, to: :variation
8
11
 
9
12
  def initialize(blob, variation)
10
13
  @blob, @variation = blob, ActiveStorage::Variation.wrap(variation)
@@ -27,6 +30,10 @@ class ActiveStorage::VariantWithRecord
27
30
  record&.image
28
31
  end
29
32
 
33
+ def filename
34
+ ActiveStorage::Filename.new "#{blob.filename.base}.#{variation.format.downcase}"
35
+ end
36
+
30
37
  delegate :key, :url, :download, to: :image, allow_nil: true
31
38
 
32
39
  private
@@ -70,7 +70,13 @@ module ActiveStorage
70
70
  has_one :"#{name}_attachment", -> { where(name: name) }, class_name: "ActiveStorage::Attachment", as: :record, inverse_of: :record, dependent: :destroy, strict_loading: strict_loading
71
71
  has_one :"#{name}_blob", through: :"#{name}_attachment", class_name: "ActiveStorage::Blob", source: :blob, strict_loading: strict_loading
72
72
 
73
- scope :"with_attached_#{name}", -> { includes("#{name}_attachment": :blob) }
73
+ scope :"with_attached_#{name}", -> {
74
+ if ActiveStorage.track_variants
75
+ includes("#{name}_attachment": { blob: { variant_records: { image_attachment: :blob } } })
76
+ else
77
+ includes("#{name}_attachment": :blob)
78
+ end
79
+ }
74
80
 
75
81
  after_save { attachment_changes[name.to_s]&.save }
76
82
 
@@ -24,9 +24,13 @@ module ActiveStorage
24
24
  # has_one_attached :thumbnail
25
25
  # end
26
26
  #
27
+ # <code></code>
28
+ #
27
29
  # # fixtures/active_storage/blobs.yml
28
30
  # first_thumbnail_blob: <%= ActiveStorage::FixtureSet.blob filename: "first.png" %>
29
31
  #
32
+ # <code></code>
33
+ #
30
34
  # # fixtures/active_storage/attachments.yml
31
35
  # first_thumbnail_attachment:
32
36
  # name: thumbnail
@@ -9,8 +9,8 @@ module ActiveStorage
9
9
  module VERSION
10
10
  MAJOR = 7
11
11
  MINOR = 0
12
- TINY = 8
13
- PRE = "6"
12
+ TINY = 10
13
+ PRE = nil
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activestorage
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.8.6
4
+ version: 7.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-10-23 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: activesupport
@@ -16,56 +15,56 @@ dependencies:
16
15
  requirements:
17
16
  - - '='
18
17
  - !ruby/object:Gem::Version
19
- version: 7.0.8.6
18
+ version: 7.0.10
20
19
  type: :runtime
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
23
  - - '='
25
24
  - !ruby/object:Gem::Version
26
- version: 7.0.8.6
25
+ version: 7.0.10
27
26
  - !ruby/object:Gem::Dependency
28
27
  name: actionpack
29
28
  requirement: !ruby/object:Gem::Requirement
30
29
  requirements:
31
30
  - - '='
32
31
  - !ruby/object:Gem::Version
33
- version: 7.0.8.6
32
+ version: 7.0.10
34
33
  type: :runtime
35
34
  prerelease: false
36
35
  version_requirements: !ruby/object:Gem::Requirement
37
36
  requirements:
38
37
  - - '='
39
38
  - !ruby/object:Gem::Version
40
- version: 7.0.8.6
39
+ version: 7.0.10
41
40
  - !ruby/object:Gem::Dependency
42
41
  name: activejob
43
42
  requirement: !ruby/object:Gem::Requirement
44
43
  requirements:
45
44
  - - '='
46
45
  - !ruby/object:Gem::Version
47
- version: 7.0.8.6
46
+ version: 7.0.10
48
47
  type: :runtime
49
48
  prerelease: false
50
49
  version_requirements: !ruby/object:Gem::Requirement
51
50
  requirements:
52
51
  - - '='
53
52
  - !ruby/object:Gem::Version
54
- version: 7.0.8.6
53
+ version: 7.0.10
55
54
  - !ruby/object:Gem::Dependency
56
55
  name: activerecord
57
56
  requirement: !ruby/object:Gem::Requirement
58
57
  requirements:
59
58
  - - '='
60
59
  - !ruby/object:Gem::Version
61
- version: 7.0.8.6
60
+ version: 7.0.10
62
61
  type: :runtime
63
62
  prerelease: false
64
63
  version_requirements: !ruby/object:Gem::Requirement
65
64
  requirements:
66
65
  - - '='
67
66
  - !ruby/object:Gem::Version
68
- version: 7.0.8.6
67
+ version: 7.0.10
69
68
  - !ruby/object:Gem::Dependency
70
69
  name: marcel
71
70
  requirement: !ruby/object:Gem::Requirement
@@ -136,6 +135,7 @@ files:
136
135
  - app/models/active_storage/blob/analyzable.rb
137
136
  - app/models/active_storage/blob/identifiable.rb
138
137
  - app/models/active_storage/blob/representable.rb
138
+ - app/models/active_storage/blob/servable.rb
139
139
  - app/models/active_storage/current.rb
140
140
  - app/models/active_storage/filename.rb
141
141
  - app/models/active_storage/preview.rb
@@ -199,12 +199,11 @@ licenses:
199
199
  - MIT
200
200
  metadata:
201
201
  bug_tracker_uri: https://github.com/rails/rails/issues
202
- changelog_uri: https://github.com/rails/rails/blob/v7.0.8.6/activestorage/CHANGELOG.md
203
- documentation_uri: https://api.rubyonrails.org/v7.0.8.6/
202
+ changelog_uri: https://github.com/rails/rails/blob/v7.0.10/activestorage/CHANGELOG.md
203
+ documentation_uri: https://api.rubyonrails.org/v7.0.10/
204
204
  mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
205
- source_code_uri: https://github.com/rails/rails/tree/v7.0.8.6/activestorage
205
+ source_code_uri: https://github.com/rails/rails/tree/v7.0.10/activestorage
206
206
  rubygems_mfa_required: 'true'
207
- post_install_message:
208
207
  rdoc_options: []
209
208
  require_paths:
210
209
  - lib
@@ -219,8 +218,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
219
218
  - !ruby/object:Gem::Version
220
219
  version: '0'
221
220
  requirements: []
222
- rubygems_version: 3.5.16
223
- signing_key:
221
+ rubygems_version: 3.6.9
224
222
  specification_version: 4
225
223
  summary: Local and cloud file storage framework.
226
224
  test_files: []