title: rails - Paperclip file name
body: <p>using rails with Paperclip, I can use the following to get the filename during a before_create:</p>
  
  <p>extension = File.extname(photo_file_name).downcase</p>
  
  <p>How do I get JUST the file name.. Right now I have photo_file_name which provides the entire file, titlename.pdf</p>
  
  <p>i need just titlename without the .pdf</p>
  
  <p>Thanks</p>
  
  <p><strong>Updating with code:</strong></p>
  
  <p>photo.rb:</p>
  
  <pre><code>  before_create :obfuscate_file_name
  
    #Paperclip for photo
    has_attached_file :photo,
  ......
  
  
  private
  
    def obfuscate_file_name
      extension = File.extname(photo_file_name).downcase
      fileNameOnly = File.basename(photo_file_name).downcase
      self.photo.instance_write(:file_name, "#{fileNameOnly}_#{ActiveSupport::SecureRandom.hex(32)}#{extension}")
    end
  </code></pre>