Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 10th, 2012  |  syntax: None  |  size: 0.35 KB  |  hits: 7  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Open file where directory path and file name change in Ruby
  2. File.open("/public/emails/:id/:filename")
  3.        
  4. file = File.find(...)
  5. File.open("/public/emails/#{file.id}/#{file.name}.#{file.extension}")
  6.        
  7. dir = "2" # the name of dir from database entry
  8. filename = "abc"
  9. extension = ".png"
  10. path = "path/dir/#{dir}/#{filename}#{extension}"
  11.  
  12. File.open(path)