Можно костыль использовать, что-нибудь типа такого:
Модель
attr_accessor :cache_file
after_initialize :fetch_upload
def fetch_upload
options = { namespace: 'upload_cache', expire_in: 10.minutes }
file = attach.queued_for_write[:original]
if file.present?
self.cache_file = attach.original_filename
Rails.cache.write(cache_file, File.read(file.path), options)
elsif cache_file.present?
file = StringIO.new(Rails.cache.read(cache_file, options))
if file.present?
self.attach = file
self.attach.instance_write(:file_name, cache_file)
end
end
end
Вьюха
<%= f.text_field :cache_file %>
<%= f.file_field :attach %>