views:

88

answers:

2

I have a Rails app that needs to send out emails with a particular (MS Word) document attached. Where is the best place to put that document file?

In general, in my Rails app, if I do File.read("myFile.doc"), what directory or directories will it look in for that file?

A: 

I would take a look at how paperclip stores its files. It seems to create a specific subfolder for each file to avoid name clashes. Not sure how that scales and kind of hope never to find out. If you store all that in the DB (on average they might be small enough to consider it) you don't need to worry about dealing with that. Some reading that might help.

Mike Williamson
+1  A: 

"what directory or directories will it look in for that file?"

It will look for the file in the root folder of your Rails project. I recommend using the Rails.root method to find the root folder of your project and create a subfolder for the attachments to upload:

File.read(Rails.root + "attachments/myFile.doc")
Edwin V.