views:

137

answers:

0

I'm using the Polymorphic fork of Paperclip in Rails, but have been having some massive problems with regards to the overwriting of unique filenames. No matter whether I put a time-stamp (more on that in a second) or the id of the asset in the URL, if a file with the same name is uploaded subsequently, then the previous one is overwritten.

Also, it was working before, but the Time interpolation is now outputting just "0" instead of the timestamp.

module Paperclip
  module Interpolations
    def stamp(attachment, style)
      attachment.instance_read(:created_at).to_i
    end
  end
end

Now just outputs;

0

This is what my URL field is;

:url => "/assets/images/:stamp/:id_:style.:extension"

Thanks.