logesh
logesh

Reputation: 2672

how to change the name of image in model file in paperclip before saving in rails?

I am using paperclip to save images in s3. The following is the code in my model

has_attached_file :pic, :storage => :s3, :s3_credentials => "#{Rails.root}/config/s3.yml",
    :url => '/image/file/:basename.:extension',
    :path => '/image/file/:basename.:extension',
    :bucket => 'Test'

And the problem is whenever i save the image with same name, the image gets replaced if there is already an image with that name. I wanted to change the name of the file. I am saving the image during the creation of new item. So can i able to use the id of the item as name of the file so that the image will be unique? If yes then how can i do it? please help me.

Upvotes: 2

Views: 2038

Answers (1)

Related Questions