0

There is an article describing that RAILS 6.1 will support multiple storage services in one model definition.

I was happy to update to RAILS 6.1 and tried it out.

My Model :

...
has_one_attached :accom_paper, service: :upload_accom_paper
has_one_attached :extra_paper, service: :upload_extra_paper
...

My storage.yml :

upload_accom_paper:
  service: Disk
  root: <%= Rails.root.join("uploads/accom_paper") %>

upload_extra_paper:
  service: Disk
  root: <%= Rails.root.join("uploads/extra_paper") %>

But when I try to run this code, I get :

ArgumentError (Cannot configure service :upload_extra_paper for OrderNow#extra_paper):

So it seems to be the second statement of has_one_attached will NOT be supported.

svelandiag
  • 4,231
  • 1
  • 36
  • 72
Sven Kirsten
  • 478
  • 1
  • 8
  • 27
  • It seems to be working on a new fresh project. Did you make sure to follow this point `If our project is already using Active Storage and when we upgrade to Rails 6.1, we should run rake app:update to make sure service_name column is added to the internal ActiveStorageBlob model.` ? – Daniel Sindrestean Jan 08 '21 at 21:07
  • Hi Daniel, yes sure - I did run the rails app:update and the rails db:migrate. And when I have just one has_one_attached entry in the model file, it works like designed ! – Sven Kirsten Jan 09 '21 at 08:56

0 Answers0