Friday, November 17, 2023

Action Mailer bug report template, Active Storage fixes and more!

Posted by Greg Molnar

Hi, it’s Greg. Let’s explore this week’s changes in the Rails codebase.

Fix word_wrap with empty string
This pull request fixes word_wrap to return an empty string instead of nil when given an empty string.

Process preview variant when processing preview
This pull request updates ActiveStorage::Preview#processed to generate both the full-sized preview image and the requested variant. For example, attached_pdf.preview(:thumb).processed will now immediately generate the full-sized preview image and the :thumb variant of it. Previously, the :thumb variant would not be generated until a further call to e.g. processed.url.

Fix TransformJob not accepting previewables
The ActiveStorage::TransformJob is being used when an attachment has predefined variants with the preprocessed option. When you upload a file which is not an image but a previewable file like a pdf-document it failed with ActiveStorage::InvariableError. This pull request fixes that by determining if a blob is capable of being previewed. If so, a preview will be generated.

Add Action Mailer bug report template
This pull request introduces Action Mailer bug report templates for contributors to reproduce issues with failing ActionMailer::TestCase instances.

Make return value of Cache::Store#write consistent

The return value of Cache::Store#write was not specified before, and varied between backends. This pull request makes it consistent:

  • true indicates a successful write
  • nil indicates an error talking to the cache backend
  • false indicates a write that failed for another reason

This helps to distinguish the case where the key already exists from the case where there was a memcached (or Redis) error.

You can view the whole list of changes here.
We had 25 contributors to the Rails codebase this past week!

Until next time!

Subscribe to get these updates mailed to you.