Rails 3 - PaperClip for versioned images - maybe?

I hope to hear your recommendations on using paper clips for versioned images.

Does anyone know of any elegant paper_clip image, versioning solutions?

Use Case, User Loads an image. The user then downloads the image to replace the previous update. The user can see the trace of the images.

thank

+3
source share
1 answer

I will do something like this

class Attachment < ActiveRecord::Base
  belongs_to :user
  has_attached_file :image
end

class User < ActiveRecord::Base
  belongs_to :current_attachment, class_name: 'Attachment'
  has_many :attachments, order: 'attachments.created_at ASC'
end

and in the controller that processes the image loading after successfully creating a new attachment entry, replace the existing user_current_attachment with the newly created one.

, counter_cache , , before_create .

0

Source: https://habr.com/ru/post/1772549/


All Articles