Useful or not, from you.
rails `ActiveStorage::Current.host` not set causing disk service to throw `URI::InvalidURIError`

Steps to reproduce

config/storage.yml:

test:
  service: Disk
  root: <%= Rails.root.join("tmp/storage") %>

local:
  service: Disk
  root: <%= Rails.root.join("storage") %>
  public: true

config/environments/development.rb:

  # Store uploaded files on the local file system (see config/storage.yml for options).
  config.active_storage.service = :local

app/models/user.rb:

class User < ApplicationRecord
  validates :username, presence: true

  has_one_attached :avatar

Expected behavior

In rails console:

irb> ActiveStorage::Current.host
=> nil

irb> User.find_by_username('david').avatar.url
=> [should generate permanent url]

Actual behavior

In rails console:

irb> ActiveStorage::Current.host
=> nil

irb> User.find_by_username('david').avatar.url
URI::InvalidURIError (bad URI(is not URI?): nil)

System configuration

Rails version:

Rails 6.1.0

Ruby version:

ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-darwin19]

That's a useful answer
Without any help

There's no documents about setting ActiveStorage::Current.host before generating public permanent url using the Disk service.