[LRUG] Photo gallery with access control
David Salgado
david at digitalronin.com
Fri Apr 25 04:05:15 PDT 2008
Risky though it is to expose my crappy code to the world, you might
find this snippet helpful;
http://www.pastie.org/186719
In config/routes.rb;
map.resources :image_data
Then http://myapp/image_data/foo.png generates a request to the 'show'
action with an id of 'foo' and a format of 'png'
I've got a model called "Image" whose id is actually the filename. the
'mimetype' method is quite naive - it uses a regexp returning
"image/xxx" where 'xxx' is whatever occurs after the last dot in the
filename.
In my case, Image actually is an ActiveRecord model, but it would be
trivial create a model whose 'contents' method streamed the data from
a file.
I don't need it, but adding access control via the imagedata
controller should be simple. It's all rather noddy, but it works fine
for my purposes, so just in case it helps...
Cheers
David
On 25/04/2008, Neil Chandler <neil at speedchilli.com> wrote:
> Thanks for your help, that sounds like a good solution to me.
>
>
> _______________________________________________
> Chat mailing list
> Chat at lists.lrug.org
> http://lists.lrug.org/listinfo.cgi/chat-lrug.org
>
>
More information about the Chat
mailing list