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?
on 2007-06-28 13:38
on 2007-06-28 15:36
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
on 2007-06-28 16: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?