Rails 5.1.4 active storage MissingModelIdError

220 Views Asked by At

Rails newbie here. I am trying to upload a file to S3 via active storage through a background job. Set up everything as mentioned in this article (https://keithpblog.org/post/active-storage-on-amazon-s3/.) When I run the background job I get this error. Searched google but I couldn't find anything relevant. Can someone please help me out?

The below is how my model looks

class ReportOutput < ApplicationRecord
  has_one_attached :output_file
end

This is how I am calling it. (not sure if this is correct way)

ReportOutput.new.output_file.attach(io: File.open('./test.xlsx'), filename: 'test.xlsx')

This is the error I get.

Job exception: #<URI::GID::MissingModelIdError: Unable to create a Global ID for ReportOutput without a model id.>
0

There are 0 best solutions below