Forum: Ruby on Rails Access folders outside RAILS_ROOT

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
456c8ee026ca401775e7be9d4be85741?d=identicon&s=25 Shruthi Viswanath (shrviswa)
on 2007-06-28 11:38
How does one make available folders outside the rails root dir? For e.g
I want to create a folder of html pages in C:\. How do I make this
accessible to users of my Rails server?
Fb1a6916e06f221b5b53a6665f9858eb?d=identicon&s=25 Mikel (Guest)
on 2007-06-28 13:36
(Received via mailing list)
Dear Shruthi,

This is basically a bad idea from a security viewpoint.  It is
possible from Rails, but it is not a good idea and so, like all not so
good ideas, Rails makes it harder for you.

"The usual is easy, the uncommon is possible... but not always easy".

Doing this is actually not so hard, and is actually a web server
issue, not a rails issue.  Rails handles the rendering of your rails
pages out of the RAILS_ROOT/public directory.

Your BEST bet is to move those files out of C and put them somewhere
that your normal webserver can get to them.  But NOT in the root
directory.

If you put it in the root directory, you open up the ability for
people to go http://your.url.com/windows/server_password_file.txt

You get the idea

So you need to really go into your web server and find out what you
need to do, it is not so much rails.

Unless you are trying to get rails to send files to the users using
send_file or something in which case, just type the path in the
send_file param.  Start it with a / and you will get the root dir.

ARC

Mikel
456c8ee026ca401775e7be9d4be85741?d=identicon&s=25 Shruthi Viswanath (shrviswa)
on 2007-06-28 14:40
Thanks a lot for the info, Mikel. I think I worded my question wrongly.
I just want to render HTML pages stored in a folder which is not under
RAILS_ROOT/public directory, but is elsewhere, like C:\abcd\. So all I
want to do is switch the context from RAILS_ROOT to the other folder, to
display the static HTML pages. I dont think there's any security threat
in this case. How exactly do I do this?
This topic is locked and can not be replied to.