Wednesday, February 6, 2008

Attachment Mania

I'm sitting face to face with a problem...

That problem being the ability to add an attachment to a "message" of sorts. Think of it as attaching a file to a forum post...except not everyone should have access to this file. And we need to do this with Ruby on Rails.

So what do we need?

Well, first and foremost I suggest we create a directory which sits outside the rails app itself. Say:
/var/myapp/attachments

Brad, why in the hell do you want to do that?


Simple, these are very private files which are going to be stored. No one should be able to just key-up the path in the browser to get to them. It will save me the lawsuit and bandwidth.

The second thing we need is to free up mongrel from serving up any static files. Let mongrel handle requests for rails but let nginx handle the static file response. This little nugget will allow us to do such a thing from rails in a clear, concise manner.

The last thing we need is to alter our capistrano script to not whipe our cache of attachments each time we deploy a new version of our rails application.

I'll post a response with my findings, if anyone has any suggestions...well, you know where to post.

No comments: