On my server (running lighthttpd), relative paths start from the root of the filesystem ("\"). On my windows box (running webbridge), relative paths start from the root of the webserver. This is annoying because i need to use File.exists("dir/somefile.txt"), and i have to change all the paths when I deploy. Does anyone know how to : (a) change the starting directory for relative paths? (b) retrieve the root of the webserver from within rails? -or- (c) do anything that would allow me to run the same code in both situations? Lindsay
Have you tried Dir.chdir ? Might break a bunch of rails stuff, I doubt it, I see rails will grab the current directory in the dispatcher. Me I would just define a constant with the working dir, File.dirname(__FILE__) as the dispatcher does it, RAILS_ROOT might already be set to this. -Jeff ----- Original Message ----- From: "Lindsay" <hellolindsay-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> To: <rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> Sent: Monday, June 20, 2005 3:30 PM Subject: [Rails] relative paths not the same On my server (running lighthttpd), relative paths start from the root of the filesystem ("\"). On my windows box (running webbridge), relative paths start from the root of the webserver. This is annoying because i need to use File.exists("dir/somefile.txt"), and i have to change all the paths when I deploy. Does anyone know how to : (a) change the starting directory for relative paths? (b) retrieve the root of the webserver from within rails? -or- (c) do anything that would allow me to run the same code in both situations? Lindsay _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Woudl doing something like how it is in environment.rb help: File.exists("#{RAILS_ROOT}/dir/somefile.txt") ? On 6/21/05, Jeffrey Moss <jeff-61uStg5MtoFWk0Htik3J/w@public.gmane.org> wrote:> Have you tried Dir.chdir ? Might break a bunch of rails stuff, I doubt it, > I see rails will grab the current directory in the dispatcher. > > Me I would just define a constant with the working dir, > File.dirname(__FILE__) as the dispatcher does it, RAILS_ROOT might already > be set to this. > > -Jeff > > ----- Original Message ----- > From: "Lindsay" <hellolindsay-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > To: <rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> > Sent: Monday, June 20, 2005 3:30 PM > Subject: [Rails] relative paths not the same > > > On my server (running lighthttpd), relative paths start from the root > of the filesystem ("\"). > On my windows box (running webbridge), relative paths start from the > root of the webserver. > > This is annoying because i need to use > File.exists("dir/somefile.txt"), and i have to change all the paths > when I deploy. Does anyone know how to : > > (a) change the starting directory for relative paths? > (b) retrieve the root of the webserver from within rails? > -or- > (c) do anything that would allow me to run the same code in both situations? > > Lindsay > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
That''s what i was looking for, thanks :) Lindsay On 6/20/05, Dan Sketcher <dansketcher-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Woudl doing something like how it is in environment.rb help: > File.exists("#{RAILS_ROOT}/dir/somefile.txt") ? > > > > On 6/21/05, Jeffrey Moss <jeff-61uStg5MtoFWk0Htik3J/w@public.gmane.org> wrote: > > Have you tried Dir.chdir ? Might break a bunch of rails stuff, I doubt it, > > I see rails will grab the current directory in the dispatcher. > > > > Me I would just define a constant with the working dir, > > File.dirname(__FILE__) as the dispatcher does it, RAILS_ROOT might already > > be set to this. > > > > -Jeff > > > > ----- Original Message ----- > > From: "Lindsay" <hellolindsay-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > To: <rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> > > Sent: Monday, June 20, 2005 3:30 PM > > Subject: [Rails] relative paths not the same > > > > > > On my server (running lighthttpd), relative paths start from the root > > of the filesystem ("\"). > > On my windows box (running webbridge), relative paths start from the > > root of the webserver. > > > > This is annoying because i need to use > > File.exists("dir/somefile.txt"), and i have to change all the paths > > when I deploy. Does anyone know how to : > > > > (a) change the starting directory for relative paths? > > (b) retrieve the root of the webserver from within rails? > > -or- > > (c) do anything that would allow me to run the same code in both situations? > > > > Lindsay > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >