Hi, in Rails using the Polymorphic version of Paperclip, the default saving technique means that files with the same name overwrite each other. Including the :id in the path and URL doesn't work as it just overwrites the earlier file with the old :id.
I've tried interpolations using a time-stamp, but it just looks for the current time when being shown the image (plus as I have multiple thumbnails it takes longer than a second, therefore the images have different stamps).
Paperclip.interpolates :uniqueid do |attachment, style|
Time.now.to_i.to_s
end
Also tried using a hex number, but it iterates through for each thumb, thus breaking as there's a new hex value each time.
Paperclip.interpolates :uniqueid do |attachment, style|
ActiveSupport::SecureRandom.hex(3)
end
As it's the Polymorphic version, and thus has it's own model, I don't know how to access the values from the parent model (in this case "Post"). Variations on the code below all throw up "undefined method" errors.
Paperclip.interpolates :user_id do |attachment, style|
current_user.id
end
Sorry if it seems a newbie question, but it's well document for the traditional Paperclip, but nothing is out there for the Polymorphic fork.