【发布时间】:2018-02-11 18:07:59
【问题描述】:
我无法使用 服务对象 中的 Active Storage 将 JSON 临时文件附加到模型。这很容易复制:
型号:
class ServiceRequest < ApplicationRecord
has_one_attached :data_file
流程:
temp_file = Tempfile.new([SecureRandom.uuid, '.json'])
@service_request.data_file.attach(temp_file)
错误:
ActiveRecord::RecordNotSaved (Failed to save the new associated data_file_attachment.)
我在ServiceRequest 模型上将data_file 定义为string。不知道问题出在哪里。
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-5 rails-activestorage