Buddy Lindsey
Buddy Lindsey

Reputation: 3630

Routing to a Location on the Server

I have several custom routes in my rails 3.0 app, the simplest one of which is.

match "*user", "profile#index", :via => :get

Because of that route physical locations on the server are killed. As an example.

/images/rails.png 

tries to route to the images user.

I also have to be able to setup where people access

/<username>/archive.zip

So

/buddy/archive.zip

Where the archive.zip is a physical file on the server that has been generated and put there. How can I achieve this in my routing.

For the later I have an actual folder structure in a root folder for /<username>/archive.zip so I was thinking somem sort of symlink would be easy, but without being able to hit physical locations on the server. I am kind of stuck/confused.

Any help is appreciated.

Upvotes: 0

Views: 71

Answers (1)

Cluster
Cluster

Reputation: 5626

You probably want to have any static assets get handled by your web server before hitting your rails stack. This is generally done by setting the document root in your webserver to the public/ directory within your rails app to serve your static images/css/js.

This is greatly preferred over allowing Rails to serve static assets because web servers are much faster at handling these sorts of requests, and your not tying up your rails processes for these requests, which are often limited to less than a handful.

Upvotes: 1

Related Questions