0

I would like to migrate from Paperclip to Carrier Wave or Refile because of this. The solution written here is impressive, but strikes me as complex and perhaps brittle.

My Rails4 app has 100's of images in production that were uploaded with Paperclip. Files are stored on production server. I have looked for a complete set of steps to follow to migrate, but keep coming up empty.

Is there a set of steps one can follow that allows for migration without necessitating application code re-write?

Alternatively, is there another way to persist uploaded files in Paperclip when form validation fails?

What am I missing here?

UPDATE:

Tried the solution detailed here by https://stackoverflow.com/users/646389/galatians . My paperclip :path and :url interpolations make use of :id_partition. I don't see a way this can be reconciled with an uploaded Image that is staged, but not yet saved.

Community
  • 1
  • 1
Perry Horwich
  • 2,798
  • 3
  • 23
  • 51

2 Answers2

1

I migrated to Carrierwave. Here are the relevant stats:

  • Time to work on and fail at coding a solution for persistent files across form reloading with Paperclip - 4 hours. See OP update for the issue I could not overcome.
  • Time to Migrate to carrierwave, adjust the relevant models, controllers, and forms, and test. - 2 hours. Not so bad.

This key info helped me adjust the paths correctly. Keeping the path identical was important to me for avoiding having to move images to a new location in production:

  • Carrierwave code for generating paperclip-like :path and :url info here.
  • Paperclip interpolation info here.
  • This link got me on the right track, although my default :path made use of :id_partition not :id.

UPDATE: Migration breaks this paradigm:

  @protocol.images.each do |i|  
    tmp=i.dup  
    tmp.avatar = File.open(i.avatar.current_path)  
    tmp.save!  
    @dest.images << tmp          
  end  

See: Duplicating a record that contains a carrierwave avatar : Getting "can't convert nil into Integer" error

Community
  • 1
  • 1
Perry Horwich
  • 2,798
  • 3
  • 23
  • 51
0

You don't need to do anything because the only data needed to get images is already stored in DB.

egoholic
  • 317
  • 1
  • 6
  • Well, there's this: http://stackoverflow.com/questions/32449069/wrong-url-with-migrating-paperclip-to-carrierwave and this: http://stackoverflow.com/questions/21640866/rails-convert-paperclip-directory-structure-to-carrierwave ... to wonder about. Have seen others with unexpected outcome. – Perry Horwich Aug 25 '16 at 00:31