RailsCasts Pro episodes are now free!

Learn more or hide this

idvix's Profile

GitHub User: idvix

Site: http://idvix.com

Comments by

Avatar

Hi,

I need files to be renamed before uploading
I get this to work :

ruby
    def key
      @key ||= "uploads/#{SecureRandom.hex}"
    end

But I need the extension at the end and this doesn't work:

ruby
    def key
      @key ||= "uploads/#{SecureRandom.hex}" + File.extname("${filename}")
    end

Thanks for the help