Best way to reference uploads in a plugin


#1

The issue of disappearing uploads has been discussed here before. I just stumbled on the same error in a plugin of mine and started thinking about how to reference uploads. My guess is that Sidekiq determines if an Upload is an orphan if it doesn’t have a PostUpload relation. If so is it enough to have a has_one or has_many relationship in my referencing class? Or would the reference also have to be in the Upload class such as the existing relation beneath?

has_many :post_uploads, dependent: :destroy
has_many :posts, through: :post_uploads

This is really an Active Record question but it would help to get a hint.

Thanks