Rails equivalent to J2EE getRequestDispatcher().forward(...) or PHP @readfile(...)

Hello Rails community

Is there a Rails equivalent to the J2EE
getRequestDispatcher().forward(...) or
the getRequestDispatch().include(...), or,
say, the PHP @readfile(...) ?

In particular, what I would like to do is first authenticate
for permission, and if permitted, serve static content.
The J2EE forward and include mechanisms allow content
to be served without the service URL showing up in the
URL bar in the client browser. This means that the original
request can contain necessary static content location
information, but after permission is ascertained, the full
path to the content is assembled and passed only internally
within the server.

Maurice Yarrow

It sounds like you want to do a reverse proxy. I do recall someone on
the Rails wiki posting some code to do that. However I'd be hesitant to
do it for real unless you had just a few things you wanted to

If your Rails app is the main application and you just want to expose
some back end static content for authenticated users then the wiki
solution should work fine. Any more than that then I'd recommend
investigating a real reverse proxy solution and have your apps and
content sit behind that and let it take care of authentication.


A pretty close equivalent of this would be render_component, but
components add significant overhead and are slated to be deprecated.

After seeing the other replies I realize that I misunderstood what you
were saying. The talk of URLs made me think the static content was on a
different web server. But I think you mean you have static content
outside the document root that you want to serve to clients that you
first authenticate via your rails app. That's easier. :slight_smile:

Try send_file,