Ruby on rails 如果从redis作业中的渲染器内调用,则image_path返回错误的url

Ruby on rails 如果从redis作业中的渲染器内调用,则image_path返回错误的url,ruby-on-rails,redis,Ruby On Rails,Redis,带有ActiveStorage的Rails 6应用程序有一个应用程序帮助程序,可返回用户的配置文件映像 module ApplicationHelper def profile_picture_with_class user, css_class, shape, width = 100 if (shape == :square) placeholder_pic = "blank_profile_square.jpg"

带有ActiveStorage的Rails 6应用程序有一个应用程序帮助程序,可返回用户的配置文件映像

 module ApplicationHelper
        def profile_picture_with_class user, css_class, shape, width = 100
            if (shape == :square)
                placeholder_pic = "blank_profile_square.jpg"
            else
                placeholder_pic = "blank_profile_round.png"
            end
            image_path = user.profile_image.present? ? user.profile_image : placeholder_pic
            image_tag(image_path, width: width, class: css_class)
        end 
    end
当从应用程序内部调用此applicationHelper时,它工作正常。但是,如果redis作业使用此applicationHelper,则返回的image_标记将取代my apps实际主机(开发中的localhost:3000),这将创建一个非常断开的链接

我猜,因为这是在redis作业中触发的,它不知道主机是什么,所以它准备了其他东西。如何让it人员了解如何使用正确的主机和活动存储类型(磁盘与blob)

谢谢

创建的两个链接的比较:

例如:

Redis返回以下内容:

http://example.org/rails/active_storage/blobs/<big_long_chunk>/new-chimney-crown.jpg
http://localhost:3000/rails/active_storage/disk/<big_long_chunk>/new-chimney-crown.jpg?content_type=image%2Fjpeg&disposition=inline%3B+filename%3D%22new-chimney-crown.jpg%22%3B+filename%2A%3DUTF-8%27%27new-chimney-crown.jpg
因此,无论出于何种原因,在example.com运行时,默认值都会重置为example.com。如果我创建一个渲染器并专门设置它的主机(和ssl),它似乎可以正常工作。SSL也必须正确设置,否则将无法工作

因此,无论出于何种原因,在example.com运行时,默认值都会重置为example.com。如果我创建一个渲染器并专门设置它的主机(和ssl),它似乎可以正常工作。SSL也必须正确设置,否则将无法工作

  def perform(chat_message)
    ActionCable.server.broadcast "stream:#{chat_message.stream.id}", {
        chat_message: ChatMessagesController.render(chat_message)       
    }
  def perform(chat_message)
    # ChatMessagesController.renderer.defaults[:http_host] = ENV['RAILS_APPLICATION_URL'].presence || 'http://localhost:3000' 

    renderer = ChatMessagesController.renderer.new(
      http_host: ENV['RAILS_APPLICATION_URL'].presence || 'http://localhost:3000' ,
      https:      Rails.env.production?
    )

    ActionCable.server.broadcast "stream:#{chat_message.stream.id}", {
        chat_message: renderer.render(chat_message)         
    }

  end