Forum: Ruby on Rails Rails app supplying image to a static page?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
mksys (Guest)
on 2008-12-30 09:18
(Received via mailing list)
Can anyone help point me in the right direction on doing the

Say I have a Rails app that deals with photos at,
and I also have a legacy site at

What I would like to do is from a static html page on
have a random photo displayed from the photo app.

So, if I put something like this in my static page: <img src="http://" />
would it be possible when a user hits the static page to have it
routed to an action that would pull a random photo and return it to
the static page in the form of an image?

Thanks in advance.
MaD (Guest)
on 2008-12-30 10:39
(Received via mailing list)
well, i don't know much about your rails app. so i can't tell you how
exactly you should do it. but generally spoken: yes, that should be
possible. actually in exactly the way you proposed.
Simon M. (Guest)
on 2008-12-30 10:52
(Received via mailing list)
Hi Mark,

I would be inclined to create a controller and have an action on it that
serves up a random image.

This would make your static URL something like

Create a controller called random, and an action called pic (you can
these anything, or even use the default index action). In your action,
just pick a random image and serve it back to the browser.

We do something similar, without the randomness to serve images to
external applications.

This topic is locked and can not be replied to.