【问题标题】:Error in view: The asset "ABCD" is not present in the asset pipeline视图错误:资产管道中不存在资产“ABCD”
【发布时间】:2022-08-15 03:39:37
【问题描述】:

我正在从载波迁移到活动存储,因此我添加了以下模型更改以及 InstallationConfiguration 在此 doc 中提到的更改

模型:

  mount_uploader :file, PatientUploader
  has_one_attached :file_new

我能够通过 rake 任务成功测试更改,但现在我正尝试通过上传 pdf 文件从 UI 测试它。我也可以按原样使用视图更改来测试更改,但稍后我将删除 mount_uploader 更改(所有载波更改),因此我必须更新视图,因此我尝试在视图中进行更改。

我在视图中更新了以下行 从

= link_to patient.name, patient.file_url, target: \"_blank\", class: \'external\'

= link_to image_tag(patient.name), patient.file, target: \"_blank\", class: \'external\'

但我得到了错误The asset \"ABCD\" is not present in the asset pipeline.

我没有在项目的任何地方设置config.assets.compile,因为我在一些堆栈线程上看到它不是一个好习惯。

我想知道为什么在更新视图后会出现此错误以及如何解决它?

谢谢

    标签: ruby-on-rails rails-activestorage


    【解决方案1】:

    假设“ABCD”是患者的姓名。

    你给image_tag patient.name,但image_tag 需要某种源变量:

    源可以是完整路径、文件或活动存储附件。

    如果patient.file 是活动存储附件:

    = link_to patient.name, target: "_blank", class: 'external' do
      image_tag(patient.file)
    
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-12-27
      • 2023-03-26
      • 1970-01-01
      • 2021-09-11
      • 1970-01-01
      • 2019-09-18
      • 1970-01-01
      相关资源
      最近更新 更多