Sign in through GitHub

Please read for an updated status on RailsCasts:

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