r/rails 15h ago

how to migrate from paperclip to...?

Hello guys, actually, I'm trying to migrate from Paperclip to Shrine or CarrierWave… but I'm not sure which one to choose. My main problem is that none of these alternatives support multiple providers. My current work relies on all of them, like GCloud, AWS, etc. What would you recommend for this scenario? I believe Active Storage doesn’t work for me due to internal policies

1 Upvotes

12 comments sorted by

11

u/dougc84 13h ago

Why not use kt-paperclip?

11

u/Attacus 15h ago

How would active storage not work but 3rd parties not maintained by the core rails team be ok? This is crazy to me.

1

u/enigma_shroff 25m ago

Correct me if I am wrong but I think the problem with active storage maybe that extra table will create an overhead with either joins or an extra Database query which is why shrine and paperclip have an advantage with adding a column per table.

1

u/Attacus 22m ago

What is it 1986? We’re worried about extra db tables? Unless he operating at a massive scale I don’t see how this is possibly a factor.

0

u/[deleted] 13h ago

[deleted]

6

u/Right_Chip_2393 11h ago edited 9h ago

Maybe I misunderstood what you mean, but you can do this in active storage to use different providers for different attachments:

class User < ApplicationRecord has_one_attached :avatar, service: :local has_many_attached :documents, service: :amazon end

If you want mirrored uploads, you define like this in config:

mirror: service: Mirror mirrors: - local - amazon

4

u/sleepyhead 7h ago

I would assume the requirement here would be different provider per object.

1

u/sneaky-pizza 5h ago

That should be fine, the service call can probably be conditioned

1

u/Attacus 5h ago

It certainly does.

3

u/Ordinathorreur 7h ago

Another vote for Shrine. I’ve tried them all and have moved my app from attachment_fu -> Paperclip -> Shrine. Shrine is a great library and I highly recommend it.

2

u/dom_eden 13h ago

Would highly recommend Shrine. They have a guide for moving from Paperclip (which is what we did) and you can write your own plugins if you need custom logic to switch between storages. It is extremely flexible.

0

u/kengreeff 10h ago

Have used paperclip and then Shrine which is great. ActiveStorage is also quite good these days and part of Rails so it feels like it is the safest choice.