如何将ActiveStorage附件下载到tmpdir

Guy*_*ile 6 ruby-on-rails rails-activestorage

目标是将附件下载到tempdir以供后续使用.文档说要使用ActiveStorage::Blob#open看起来很简单.

我收到错误所以请解释我做错了什么:

  1. 调用@flower.photo.open结果NoMethodError (private method 'open' called for #<ActiveStorage::Attached::One:0x00007f9780625100>)
  2. 调用@ flower.photo.blob.open`会导致 NoMethodError (private method 'open' called for #<ActiveStorage::Blob:0x00007f9780615c50>)

检查源代码我不知道为什么我得到私有方法错误.

Guy*_*ile 5

该方法直到明年的Rails 6才发布。

这里有一个类似的SO问题,提供了更多信息和建议。