Map.resources routing question

I am just learning RESTful design and trying to redesign my application
to follow the paradigm, but I am still confused about how to tackle
certain things.

I have a model called Upload and naturally a controller called
UploadsController. Its show action simply uses the send_file method to
display an image to the user, but sends the file with a filename
different from that which is on the fileserver (this is so all uploaded
files can have random filenames on the server yet be sent to users with
their original filename).

So /uploads/real_filename.jpg/fake_filename.jpg would be the URL.
Unfortunately I am having trouble making this work with the upload_path
method as it is, since it only takes :id and I need to specify two
params, the original filename and the replacement filename. When I try
to make my own named route, map.upload, then it ruins the upload_path
method for PUT and DELETE.

I even tried to just send “real_filename.jpg/fake_filename.jpg” as the
id for upload_path and then user the action to split the :id along the
forward slash, but unfortunately Rails turns that “/” into the entity
“%2F” in the URL, which looks wrong in the browser address bar.

Am I misusing my UploadsController’s show method? It seemed
appropriate, but being less anal about the whole deal I could use either
a different method or a different named route for what I’m trying to
achieve. Even still I’m curious as to know if what I’m trying to
achieve is even practical and how it could be done.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs