Reputation: 681
If I save two files with similar filenames which will go into the same directory, one will overwrite another. How to make to work the following way, let's say, there is already picture.jpg in a directory, and if I paperclip uploads another picture.jpg into the same directory, it will automatically rename it to picture-1.jpg and so on. Thanks in advance.
Upvotes: 1
Views: 191
Reputation: 19879
Configure the attachment to include the primary ID of the record to ensure there can't be duplicates... something like this:
:path => ':rails_root/public/system/assets/photos/:id/:style.:extension',
:url => '/system/assets/photos/:id/:style.:extension'
To be clear... the above also removes the original filename, but there's an expansion keyword to get that back in as well... I just never use it.
Upvotes: 2