Commit Graph

1002 Commits

Author SHA1 Message Date
Rafael Mendonça França e572f23150
Merge pull request #47094 from zzak/rack-3-files-continued
Replace deprecated Rack::File with Rack::Files
2023-01-25 16:41:12 -05:00
David Heinemeier Hansson 2b1fa89e44
Log to stdout in production by default (#47138)
* Logging to a file doesn't make sense in production

You're going to run out of space, and it doesn't play well with containers. Either you log to STDOUT, and let your container setup aggregate the logs, or you'll be switching to syslogger or whatever. You won't be logging to a file in production any more.

* Remove from Dockerfile too

* Did not mean to change this default

But we should make it easy to see how to change it.

* Restore what we had
2023-01-25 21:10:22 +01:00
David Heinemeier Hansson e8f481b924
Turn on static file server by default (#47137)
Modern deployments don't need NGINX/Apache when using CDNs or caching LBs in front. This means file serving works out of the box too.
2023-01-25 18:19:05 +01:00
Alex Ghiculescu e18c23fc2b Make `raise_on_missing_translations` raise on any missing translation
Fixes https://github.com/rails/rails/issues/47057
Superseeds https://github.com/rails/rails/pull/45361
2023-01-23 10:17:11 -07:00
zzak 12de399ef9 Replace deprecated Rack::File with Rack::Files
Follow up to #47075
2023-01-21 09:34:21 +09:00
Rafael Mendonça França 5c835bd669
Make explicit this config only affects controllers are views 2023-01-19 20:21:29 +00:00
Ghouse Mohamed e0559d2c1c Change 2022 -> 2023 2023-01-03 13:22:00 +05:30
Hartley McGuire a07f2ace03
Fix lots of code highlighting issues
The most common is replacing back-ticks with either pluses or tt tags.
There were also a few instances of code blocks not being indented.
2022-11-29 00:51:02 -05:00
Étienne Barrié 3d6a7b2faa Initialize deprecators before configuring them
Since engine initializers run later in the process, we need to run this
initializer earlier than the default.

This ensures they're all registered before the environments are loaded.
2022-11-28 10:47:26 +01:00
Rafael Mendonça França 153777d3eb
Merge pull request #46548 from Earlopain/blob-rewindable
Validate ActiveStorage::Blob io is rewindable
2022-11-23 13:51:29 -05:00
Earlopain 4a4922b7d3
Validate ActiveStorage::Blob io is rewindable
ActiveStorage::Blob.create_and_upload!(io: file_fixture("test.jpg"), filename: "dummy")

The code looks reasonable, but actually results in an infinite loop
before this change. Now an error is propagated to the user instead.
Closes #46507
2022-11-23 19:10:20 +01:00
Earlopain 1b414d9eb3
Remove ActiveStorage::Blob classic mode gotcha
Zeitwerk is the default and only mode in Rails 7
2022-11-22 13:16:52 +01:00
Jonathan Hefner ec4e34034d Remove unnecessary link markup [ci-skip]
Because they are CamelCase, RDoc will automatically link these
references.  Automatic links have monospace formatting, whereas, in some
cases, manual links do not.
2022-11-15 13:57:15 -06:00
Jonathan Hefner ee8d9497dd Auto-link code references [ci-skip] 2022-11-15 13:57:15 -06:00
Jonathan Hefner 07cd0322bd Add ActiveStorage.deprecator
This commit adds `ActiveStorage.deprecator` and replaces all usages of
`ActiveSupport::Deprecation.warn` in `activestorage/lib` and
`activestorage/app` with `ActiveStorage.deprecator`.

Additionally, this commit adds `ActiveStorage.deprecator` to
`Rails.application.deprecators` so that it can be configured via
settings such as `config.active_support.report_deprecations`.
2022-10-31 17:04:48 -05:00
Jonathan Hefner 523ae78955 Fix invalid content type deprecation warning
This fixes the following warning when running Active Storage tests:

  ```
  DEPRECATION WARNING: image/jpg is not a valid content type, it should not be used when creating a blob, and support for it will be removed in Rails 7.1. If you want to keep supporting this content type past Rails 7.1, add it to `config.active_storage.variable_content_types`. Dismiss this warning by setting `config.active_storage.silence_invalid_content_types_warning = true`.
  ```

Note that this test should eventually be removed.  It was written to
test the fix from #42225; however, after the deprecation from #42227 is
complete and invalid content types have been removed from
`config.active_storage.variable_content_types`, calling `variant` when
the content type is invalid will raise `ActiveStorage::InvariableError`
(instead of the `NoMethodError` mentioned in #42225 / #41777).  And that
behavior is already tested by the "variation of invariable blob" test.
2022-10-26 16:39:57 -05:00
Chedli Bourguiba 0b8496fa7e Add preview to `ActiveStorage::LogSubscriber`
a `preview` event is being instrumented in `ActiveStorage::Previewer`. However it is not added inside ActiveStorage's `LogSubscriber` class.
2022-10-20 23:07:51 +02:00
Jean Boussier d917896f45 Enable verbose mode in test and report warnings as errors
We recently let a few very easy to avoid warnings get merged.
The root cause is that locally the test suite doesn't run in
verbose mode unless you explictly pass `-w`.

On CI warnings are enabled, but there is no reason to look at the
build output unless something is failing. And even if one wanted
to do that, that would be particularly work intensive since warnings
may be specific to a Ruby version etc.

Because of this I believe we should:

  - Always run the test suite with warnings enabled.
  - Raise an error if a warning is unexpected.

We've been using this pattern for a long time at Shopify both in private
and public repositories.
2022-10-11 09:25:18 +02:00
Deepak Mahakale 0d1633c8c7 Add pre-defined variant examples 2022-10-10 23:25:10 +05:30
Eileen M. Uchitelle 7de6670438
Merge pull request #45837 from hahmed/ha/active-storage-fix-rotation-test-failing
FFmpeg (5.0+) has updated the tag where rotation info is retrieved from
2022-09-27 15:17:00 -04:00
John Bampton 2f699c51ce Fix word case. `html` -> `HTML` 2022-09-18 04:21:22 +10:00
Jean Boussier d96612d3ca
Merge pull request #45911 from fatkodima/invalid-range-disk-controller
[ActiveStorage] Return "Range Not Satisfiable" return code for partial downloads with incorrect range
2022-09-02 08:29:52 +02:00
compeak 506e357f00
update migration version from 5.2 to 7.0 2022-09-01 16:54:42 +02:00
fatkodima bc2aad4ae4 [ActiveStorage] Return "Range Not Satisfiable" return code for partial downloads with incorrect range
Co-authored-by: Hartley McGuire <skipkayhil@gmail.com>
2022-08-31 00:39:33 +03:00
Haroon Ahmed 206a826c8d Fix failing ActiveStorage test due to a change upstream in ffmpeg.
The original code which pulls the rotation from tags is still left for
older ffmpeg versions whilst the newer ffmpeg version 5.0+ will use the
side_data to retrieve the rotation info.
2022-08-26 15:25:53 +01:00
Jean Boussier bd19d1baf1 Optimize AS::LogSubscriber
The various LogSubscriber subclasses tend to subscribe to events
but then end up doing nothing if the log level is high enough.

But even if we end up not logging, we have to go through the
entire notification path, record timing etc.

By allowing subscribers to dynamically bail out early, we can
save a lot of work if all subscribers are silenced.
2022-08-12 09:58:17 +02:00
Eileen M. Uchitelle cf0873010a
Merge pull request #45743 from deepakmahakale/fix-test-case
Fix test case to check has_many_attached
2022-08-03 16:33:02 -04:00
Deepak Mahakale 380cd17ae4 Fix attachment to has_many_attached 2022-08-03 15:09:49 +05:30
Hartley McGuire 0a97813328
Fix some deprecation warnings in many_test
The append_on_assign helper function sets
ActiveStorage.replace_on_assign_to_many = false, which is deprecated.
Therefore, any tests using this helper should be using assert_deprecated
to not pollute test output. Some of them were doing this already, but
these two were not.
2022-07-26 22:41:54 -04:00
Nate Matykiewicz 294c271062
Touch model records after ActiveStorage::Blob is analyzed
This fixes a race condition where a record can be requested and have a
cache entry built, before the initial `analyze_later` completes, which
will not be invalidated until something else updates the record.

1. Upload attachment (this will create an ActiveStorage::Blob,
   ActiveStorage::Attachment, and touch the model)
2. Enqueue analyze job
3. Request record
4. Build a cache for that record
5. Analyze the attachment.
6. Request the record again
7. Serve a cache that doesn't include data from the analyzers, because
   the cache was built before it got analyzed, and the updated_at
   hasn't changed.

This also invalidates cache entries when a blob is re-analyzed, which
is helpful if a bug is fixed in an analyzer or a new analyzer is added.

Fixes #45567
2022-07-26 10:39:44 -05:00
Richard Böhme acf767dbd6 Allow to use pre-defined variants for previews
Previously, named variants could only be used when calling the
`variant` method on an attachment. For files that are not `variable?`
but `previewable?` those pre-defined variants could not be used.

With this patch, the methods `preview` and `representation` also allow
to be passed a variation name as a symbol.

    class User < ActiveRecord::Base
      has_one_attached :file do |attachable|
        attachable.variant :thumb, resize_to_limit: [100, 100]
      end
    end

    <%= image_tag user.file.representation(:thumb) %>
2022-07-19 16:59:52 +02:00
Jonathan Hefner c5133f0010 Require ruby-vips before downloading blob
This ensures that if `download_blob_to_tempfile` raises an error before
evaluating its block, `rescue ::Vips::Error` will not cause a
`NameError` due to `ruby-vips` not being loaded yet.

This also prevents the blob from being downloaded if `ruby-vips` is not
available to analyze it.

A similar change was made for `Analyzer::ImageAnalyzer::ImageMagick`
in #45420.
2022-06-23 12:50:08 -05:00
eileencodes 9766eb4a83
Fix tests for minitest 5.16
In minitest/minitest@6e06ac9 minitest changed such that it now accepts
`kwargs` instead of requiring kwargs to be shoved into the args array.
This is a good change but required some updates to our test code to get
the new version of minitest passing.

Changes are as follows:

1) Lock minitest to 5.15 for Ruby 2.7. We don't love this change but
it's pretty difficult to get 2.7 and 3.0 to play nicely together with
the new kwargs changes. Dropping 2.7 support isn't an option right
now for Rails. This is safe because all of the code changes here are
internal methods to Rails like assert_called_with. Applications
shouldn't be consuming them as they are no-doc'd.
2) Update the `assert_called_with` method to take any kwargs but also
the returns kwarg.
3) Update callers of `assert_called_with` to move the kwargs outside the
args array.
4) Update the message from marshaled exceptions. In 5.16 the exception
message is "result not reported" instead of "Wrapped undumpable
exception".

Co-authored-by: Matthew Draper <matthew@trebex.net>
2022-06-23 08:32:11 -04:00
Joel Cogen 95322be0ed require mini_magick at the level it is being used 2022-06-21 14:50:01 -03:00
Santiago Bartesaghi 7acdfcb12c Make ActiveStorage attach method be consistent between one and many 2022-06-20 19:17:07 -03:00
Santiago Bartesaghi 75d58c8004 Fix #45339 attachments for new record within transaction
Co-authored-by: Juan Eduardo Roig <jeroig@gmail.com>
2022-06-17 17:25:18 -03:00
Santiago Bartesaghi 2895c6b9a2 Fix #41661 attaching multiple times within transaction
Co-authored-by: Abhay Nikam <nikam.abhay1@gmail.com>
Co-authored-by: Bruno Vezoli <brunvezoli@hotmail.com>
Co-authored-by: Juan Eduardo Roig <jeroig@gmail.com>
2022-06-06 21:23:33 -07:00
Ghouse Mohamed 06c83d93cf Added validation for global active storage service configuration 2022-05-31 08:36:46 -07:00
Jean Boussier 26bbb0c10c
Merge pull request #44916 from ghiculescu/image-bmp
Treat `image/bmp` as a valid content type
2022-05-21 15:18:22 -07:00
Jeremy Daer fe8d41eda1
Merge pull request #42981 from ghiculescu/as-eager-more-methods-3
Active Storage eager loading: support more methods
2022-05-16 12:42:23 -07:00
Ghouse Mohamed 1a6e13d986 Adds test coverage for #attach method behaviour in activestorage 2022-05-16 12:21:19 -07:00
Jeremy Daer f24500b3ab Merge branch 'main' into as-eager-more-methods-3
* main: (746 commits)
  Address QueryCacheTest#test_query_cache_does_not_allow_sql_key_mutation failure
  Fixes ActiveStorage proxy downloads of files over 5mb in S3-like storage services
  Fixes development Action Mailbox new mail form
  Squash commits
  Include the unexpected class in InvalidParameterKey message
  Support unbounded time ranges for PostgreSQL
  Fix CHANGELOG alignment [ci-skip]
  Add ability to ignore tables by regexp for SQL schema dumps
  Improve `rails s` error message when no server could be found.
  Fix MySQL warning when creating Active Record's test databases
  Add `--js` and --skip-javascript` options to `rails new`
  Fix parsing operator classes for index columns in PostgreSQL
  Fix rails test command to handle leading dot slash
  Document that url_for can take classes
  Don't change the encoding of frozen parameters
  Update working_with_javascript_in_rails.md
  Avoid query from calculations on contradictory relation
  Fix MemoryStore#write(name, val, unless_exist: true) with expired entry
  Provide pattern matching for ActiveModel
  Stop autoclosing of PRs
  ...
2022-05-16 12:18:30 -07:00
Felipe e4eab9892f Fixes ActiveStorage proxy downloads of files over 5mb in S3-like storage services 2022-05-16 08:09:12 -03:00
Alex Ghiculescu a22bb8fa69 Treat `image/bmp` as a valid content type
This is a follow up to https://github.com/rails/rails/pull/42227#issuecomment-1100927828

The mime types database was incorrect regarding `image/bmp`. It has been fixed in https://github.com/mime-types/mime-types-data/issues/48 and in https://github.com/discourse/mini_mime/pull/45

Since a new version of `mini_mime` hasn't been cut yet, some of the tests in this PR look a bit off. But the core issue of not warning users if they use `image/bmp` is resolved.
2022-04-19 08:08:16 +10:00
Xavier Noria 2953ae5c8a Define config.enable_reloading to be !config.cache_classes
Every time I write `config.cache_classes` I have to pause for a moment to make
sure I get it right. It makes you think.

On the other hand, if you read `config.enable_reloading = true`, does the
application reload? You do not need to spend 1 cycle of brain CPU to nod.
2022-04-14 18:11:36 +02:00
Rafael Mendonça França 5c1bd20f0d
Merge pull request #44693 from ghousemohamed/fix-docs-related-gem-versions
Fix `#version` method docs and some typos [ci-skip]
2022-03-15 16:28:07 -04:00
Ghouse Mohamed 6ee6cb554b Fix #version docs and some typos 2022-03-16 01:48:37 +05:30
Matheus Richard 414394206a Extend audio_tag and video_tag to accept Active Storage attachments.
Now it's possible to write

    audio_tag(user.audio_file)
    video_tag(user.video_file)

Instead of

    audio_tag(polymorphic_path(user.audio_file))
    video_tag(polymorphic_path(user.video_file))

image_tag already supported that, so this follows the same pattern.
2022-03-14 02:05:37 -03:00
Rafael Mendonça França d6f2e17908
Make sure allowed image processing arguments are correctly loaded
If for some reason the files that defined those constants were loaded
before the `after_initialize` block, the values of the configuration
would not be applied.

With this new implementation we always use the configuration value, so
the order things are defined doesn't matter.
2022-03-11 17:45:39 +00:00
Aaron Patterson 2c21a39493
Merge pull request #44387 from piecehealth/fix_activestorage_update
fix activestorage update
2022-03-09 16:12:48 -08:00
Hartley McGuire c3844a9dc0 fix rubocop errors
Using `bundle exec rubocop -a` and visually verified
2022-03-08 15:36:24 -05:00
Zack b2ab8dd3a4
Added image trasnformation validation via configurable allow-list
ImageProcessingTransformer now offers a configurable allow-list for
transformation methods in addition to a configurable deny-list for arguments.

[CVE-2022-21831]
2022-03-08 09:28:16 -08:00
Aaron Patterson ea9f0103fd
Revert "Revert "Merge pull request #42843 from buckley-w-david/message-verifier-default-serializer""
This reverts commit fd4e63cc28.
2022-03-01 15:14:43 -08:00
Aaron Patterson fd4e63cc28
Revert "Merge pull request #42843 from buckley-w-david/message-verifier-default-serializer"
This reverts commit a40d7815ac, reversing
changes made to ad2529be4b.
2022-03-01 13:58:40 -08:00
Saba Kiaei 5256c90327 Switch ActiveSupport::MessageVerifier's default serialization to JSON 2022-03-01 13:02:17 -05:00
Rafael Mendonça França fb88db58d7
Merge pull request #44439 from ghousemohamed/patch-6
Return the blob/blobs when #attach is able to save the record
2022-02-25 16:19:01 -05:00
Ghouse Mohamed fbfb6e6885 Return blob/blobs when #attach is able to save the record and return if it is not able to 2022-02-26 02:18:51 +05:30
Koichi ITO 819871cc4e Enable `Style/MapToHash` cop
Ruby 2.6 added block argument processing to `Enumerable#to_h`.
https://bugs.ruby-lang.org/issues/15143

Rails 7 requires Ruby 2.7.0 or higher, so the new feature can use it.
`Style/MapToHash` cop will detect it. And this cop in the `Style` department,
but this seems to improve performance as follows:

```ruby
# map_to_hash.rb
require 'benchmark/ips'

ARRAY = (1..100).to_a
HASH = {foo: 1, bar: 2}

Benchmark.ips do |x|
  x.report('array.map.to_h') { ARRAY.map { |v| [v, v * 2] }.to_h }
  x.report('array.to_h')     { ARRAY.to_h { |v| [v, v * 2] } }

  x.compare!
end

Benchmark.ips do |x|
  x.report('hash.map.to_h') { HASH.map { |k, v| [k.to_s, v * 2] }.to_h }
  x.report('hash.to_h')     { HASH.to_h { |k, v| [k.to_s, v * 2] } }

  x.compare!
end
```

```console
% ruby map_to_hash.rb
Warming up --------------------------------------
      array.map.to_h     9.063k i/100ms
          array.to_h     9.609k i/100ms
Calculating -------------------------------------
      array.map.to_h     89.063k (± 3.9%) i/s -    453.150k in  5.096572s
          array.to_h     96.449k (± 1.7%) i/s -    490.059k in  5.082529s

Comparison:
          array.to_h:    96448.7 i/s
      array.map.to_h:    89063.4 i/s - 1.08x  (± 0.00) slower

Warming up --------------------------------------
       hash.map.to_h   106.284k i/100ms
           hash.to_h   149.354k i/100ms
Calculating -------------------------------------
       hash.map.to_h      1.102M (± 2.2%) i/s -      5.527M in   5.019657s
           hash.to_h      1.490M (± 0.9%) i/s -      7.468M in   5.013264s

Comparison:
           hash.to_h:  1489707.0 i/s
       hash.map.to_h:  1101561.5 i/s - 1.35x  (± 0.00) slower
```

`Style/MapToHash` cop ... https://docs.rubocop.org/rubocop/1.25/cops_style.html#stylemaptohash
2022-02-26 04:31:03 +09:00
Ghouse Mohamed 49b4af8b3d Return blob/blobs when #attach is able to save the record and return false if it is not able to 2022-02-23 02:03:25 +05:30
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
piecehealth ead3f67e88 fix activestorage update 2022-02-10 18:01:09 +08:00
Gannon McGibbon aaa64687e8
Revert #38957 (#44287)
* Revert "Pass service_name param to DirectUploadsController"

This reverts commit 193289dbbe.

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

This reverts commit 0b69ad4de6.
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
Alex Ghiculescu 675264a449 Active Storage eager loading: support more methods
As noted at https://github.com/rails/rails/pull/40842#issuecomment-895231378, the current implementation works great with the `processed` method, but doesn't work with other methods such as `key`. This PR fixes that.

Why is this fix necessary? Currently when you call `VariantWithRecord#key`, `key` gets called on `VariantWithRecord` -> `Attached::One` -> `Attachment` -> `Blob`. This results in n+1 calls to load the `Attachment`. But for this purpose we shouldn't need to load it, as the `VariantWithRecord` already knows about it relevant `Blob`. So this PR changes the method to call directly to that blob.
2021-12-08 13:54:37 -06: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
Guillermo Iguaran 9b6011142c
Merge pull request #43119 from brian-kephart/main
Add HEIF image types to variable content types
2021-08-28 20:47:45 -07:00
Guillermo Iguaran b1b8f8aa23 Merge branch 'instrument-analyzers' of https://github.com/shouichi/rails into shouichi-instrument-analyzers 2021-08-28 00:48:44 -07:00
Brian Kephart 87f37419c4
Add HEIF image types to variable content types 2021-08-27 15:13:55 -05:00
Petrik de Heus fe9625c022
Temporarily disable Azure service tests (#43091)
The Azure service tests are currently failing on the main branch,
probably because of configuration. We can temporarily disable them while
we get things working again.
2021-08-25 11:22:39 +02:00
Petrik 0920b02c1d Upgrade azure-storage-blob to use at least 2.0.0
azure-storage-blob 1.1.0 supports ruby 1.9.3 to 2.5:
https://github.com/Azure/azure-storage-ruby/blob/v1.1.0-common/common/README.md

azure-storage-blob 2.0.0 supports ruby 2.3 to 2.7:
https://github.com/Azure/azure-storage-ruby/blob/v2.0.0-blob/common/README.md
2021-08-23 22:03:15 +02:00
Sandip Mane 458d2d3a53 Makes the array syntax consistant with other use cases 2021-08-18 23:44:58 +05:30
Shouichi Kamiya 2ad684bc49
Update activestorage/CHANGELOG.md
Co-authored-by: Petrik de Heus <petrik@deheus.net>
2021-08-17 17:59:08 +09:00
Shouichi Kamiya 35d8890c92 Instrument ActiveStorage analyzers 2021-08-17 16:55:05 +09:00
Kasper Timm Hansen ef65eeef08
Merge pull request #42960 from FestaLab/activestorage/unsafe-redirect
Fix open redirects in active storage
2021-08-16 15:29:52 +02:00
Kasper Timm Hansen 7faf8a0fe3
[ci skip] Undocument send_blob_byte_range_data, don't commit to a public API just yet 2021-08-16 15:16:54 +02:00
Kasper Timm Hansen fe4ec2ac0c
Merge pull request #41437 from tomprats/active-storage-byte-range
Added Active Storage support for byte ranges
2021-08-16 15:13:45 +02:00
Breno Gazzola b4e394767d Reduce file size of tiff image in Active Storage 2021-08-12 11:37:44 -03:00
David Heinemeier Hansson e34300a921
Stop trying to configure listen by default on compatible platforms (#42985)
* Stop trying to configure listen by default on compatible platforms

Modern computers with SSDs don't see much/any benefit from having an evented file update watcher. Remove complexity by taking this spinning-drive concession out.

* Actually need listen for testing the opt-in

* Test no longer relevant
2021-08-11 15:18:43 +02:00
Abhay Nikam 13722000ba Remove warning logged for vips variant test cases 2021-08-11 11:54:33 +05:30
Abhay Nikam 77b7835a6a Slient the deprecation warning for ActiveStorage.replace_on_assign_to_many logged in test cases 2021-08-10 22:14:52 +05:30
Abhay Nikam c89f152d8d Slient the warning for ActiveStorage::Current.host logged in test cases 2021-08-10 21:58:01 +05:30
Breno Gazzola 77f2af34f9 Fix open redirects in active storage 2021-08-06 19:14:19 -03:00
Ryuta Kamizono b87d8e51d4 Standardize :doc: comments [ci skip] 2021-08-06 17:10:45 +09:00
Tom Prats fcc46228c6 Squashed commit of the following:
commit 1dca99ad4f8082d8daaa17c6600f3036c25f8e50
Author: Tom Prats <tprats108@gmail.com>
Date:   Thu Aug 5 18:07:00 2021 -0400

    Moved header

commit 62201870ff5c4124d90912989745819b05d94516
Merge: 5fa3ecae74 c91a8135c7
Author: Tom Prats <tprats108@gmail.com>
Date:   Thu Aug 5 14:41:22 2021 -0400

    Merge branch 'main' into active-storage-byte-range

commit 5fa3ecae745b4f7c67a6b6b1b7ec420877c96fb8
Author: Tom Prats <tprats108@gmail.com>
Date:   Thu Aug 5 14:39:53 2021 -0400

    Apply suggestions from code review

    Syntax updates

    Co-authored-by: Rafael França <rafael@franca.dev>

commit b9553e3698a7af5105171f9d63bd7b89cbb7e2c3
Author: Tom Prats <tprats108@gmail.com>
Date:   Wed Jun 23 17:36:26 2021 -0400

    Added Active Storage support for byte ranges
2021-08-05 18:12:07 -04:00
Rafael Mendonça França 18707ab17f
Standardize nodoc comments 2021-07-29 21:18:07 +00:00
Rafael Mendonça França 15ed41bf2f
Merge pull request #42515 2021-07-29 01:02:23 +00:00
Rafael França 336af2e185
Merge pull request #42819 from alexcwatt/docs-representable
Representable docs: Refer to the 'variant processor' not ImageMagick
2021-07-28 20:28:55 -04:00
Rafael Mendonça França f24d10c285
Merge branch 'vips-as-default' into main 2021-07-29 00:25:41 +00:00
David Heinemeier Hansson 6c96e1cd7b
Move Active Storage JS to ESM and drop Babel transpiling (#42895)
* Move to ESM and drop Babel transpiling

* Make the activestorage JS directly available through the asset pipeline as a precompiled asset

* Use example with direct attachment

* Explain that direct reference is possible

* Active Storage JS is a module

* Retain umd asset for backwards compatibility, add ESM file in addition

* Explain how to use activestorage.esm with importmap

* Use untranspiled activestorage inclusion

* Don't repeat terser options
2021-07-28 15:17:13 -04:00
Alex Watt ebb9df43e0 Representable docs: Refer to the 'variant processor' not ImageMagick 2021-07-23 17:02:22 -04:00
Ryuta Kamizono e50b0e3ab3 Fixup CHANGELOGs [ci skip] 2021-07-21 10:08:08 +09:00
Ryuta Kamizono 9e9c563a04 ✂️ [ci skip] 2021-07-21 08:54:17 +09:00
Jonathan Hefner acfadacb07 Fix ActiveStorage::Preview#download method doc [ci-skip]
Follow-up to #42742.
2021-07-20 09:32:44 -05:00
Eileen M. Uchitelle 990bcac6f8
Merge pull request #42742 from dmarcoux/document-active_storage-preview-download
Document ActiveStorage::Preview#download [ci-skip]
2021-07-20 08:44:43 -04:00
Dany Marcoux 460a5aeecc
Document ActiveStorage::Preview#download 2021-07-20 10:24:26 +02:00
Zachary Scott c0911e9a36
Merge pull request #42740 from dmarcoux/document-active_storage-attachment-variant
Document ActiveStorage::Attachment#variant
2021-07-20 12:18:06 +09:00
Santiago Bartesaghi e9accafc84 Fix #41388 by preserving protocol and port when generating routes 2021-07-19 09:44:55 -03:00
Breno Gazzola 9bf523559f Make vips the default variant processor for new apps 2021-07-14 14:26:43 -03:00
Akanksha fd7b030b6f
Update service.rb (#42766)
* Update service.rb

The documentation for using the Active Storage from outside of the Ruby on Rails application is not according to the implementation. According to the implementation, we are looking for the env name instead of the `service` name in the configuration which is a hash( same as loading a `storage.yml`)

* Update service.rb

* Update service.rb
2021-07-14 10:13:15 -04:00
Adam P. Regasz-Rethy dfd19e1a76 Add error handling for metadata server 2021-07-13 16:09:11 -04:00
Dany Marcoux 1cfeca9cf3
Document ActiveStorage::Attachment#variant 2021-07-13 21:57:19 +02:00
Adam P. Regasz-Rethy ae90855375 Optionally use IAM for URL signing instead of :credentials 2021-07-13 15:44:08 -04:00
Dirkjan Bussink 0523532a3c
Always use OpenSSL constants for Digest operations
As also previously discussed in
https://github.com/rails/rails/pull/40770#issuecomment-748347066, this
moves the usage of Digest constants to always use the OpenSSL version of
those Digest implementations.
2021-06-30 13:57:54 +02:00
Santiago Bartesaghi 61a8cd6c8f Deprecate replace_on_assign_to_many 2021-06-28 11:22:31 -03:00