I have an application and part of its function is to display html
marked up text files to the users, inlined in the current page
layout. I have the files stored outside the Rails app directories,
and not in the database.
What I want to do is something like this in my view:
<h1>Viewing contents of filename</h1>
<%= send_file( ... ) -%>
So that my normal layout gets put around the included file.
I know I could easily create a helper, say, my_send_file that takes
the filename and returns its contents, but it means the entire file
will be pulled into memory (the files could be a reasonable size, but
not massive!). I guess if the files were in the database I would have
to pull the data out of the database into memory anyway, making this
an equivalent process.
Basically I want to know
1. Is there a builtin way to do this, or will I just go ahead and
create a helper (I don't think the send_file method is going to be any
good for me here).
2. When rendering a large page, does Rails stream it to the user, or
does it build it all in memory, and then stream it? Just curious on
this one ...