Raymond Brigleb
2005-May-13 21:20 UTC
Trouble referring to Files within /public in production...
Hello, me again! I''m having the hardest time creating a file on my server! I''m trying to create these files in sub-folders of /public such as /public/1 or / public/4 ... and these folders do exist on both my development and testing servers. And it''s working in development, but just fails in production! Here is what the code in question looks like: feed = render_component_as_string(:action => ''website'', :id => @params[:website_name]) @foldername = File.join(''public'', @params[:website_name]) @filename = "site.xml" @fullname = File.join(@foldername, @filename) File.open(@fullname, "w") { |file| file.write feed } I''m rendering my hand-rolled XML "feed" to a file, but it''s not working, it can''t "find" the file, but like I said, only on the production server (TextDrive) but not in development. Factors that might be influencing this: 1. It''s in a subdomain, not my primary domain, and Apache is responsible for directing traffic there. 2. My .htaccess is out-of-the-box standard, I''ve triple-checked... 3. My routes.rb is pretty darn vanilla. 4. The actual error message I''m seeing in my production log: Errno::ENOENT (No such file or directory - /public/1/site.xml): So I''ve tried everything I could think of, and no-one in the TextDrive forums seems to have any ideas, so I thought I''d ask on here. Any ideas? Thanks, Raymond
Jeremy Kemper
2005-May-13 21:35 UTC
Re: Trouble referring to Files within /public in production...
On May 13, 2005, at 2:20 PM, Raymond Brigleb wrote:> I''m having the hardest time creating a file on my server! I''m > trying to create these files in sub-folders of /public such as / > public/1 or /public/4 ... and these folders do exist on both my > development and testing servers. And it''s working in development, > but just fails in production! Here is what the code in question > looks like: > > feed = render_component_as_string(:action => ''website'', :id => > @params[:website_name]) > @foldername = File.join(''public'', @params[:website_name])Hey Raymond-- try @foldername = File.join(RAILS_ROOT, ''public'', params [:website_name])> @filename = "site.xml" > @fullname = File.join(@foldername, @filename) > File.open(@fullname, "w") { |file| file.write feed }Best, jeremy
Raymond Brigleb
2005-May-13 21:54 UTC
Re: Trouble referring to Files within /public in production...
> Hey Raymond-- try > @foldername = File.join(RAILS_ROOT, ''public'', params > [:website_name])Shoot, Jeremy, that was it. :) A thousand thank-yous! I suspected I was looking for something like that, but it can be a bit like trying to look up something in the dictionary that you have no idea how to spell! -raymond
Andrew Stone
2005-May-13 21:55 UTC
Re: Trouble referring to Files within /public in production...
> feed = render_component_as_string(:action => > ''website'', :id => @params[:website_name]) > @foldername = File.join(''public'', @params[:website_name]) > @filename = "site.xml" > @fullname = File.join(@foldername, @filename) > File.open(@fullname, "w") { |file| file.write feed } >Just a guess (haven''t worked much with RoR), but from the error message and this join command it seems to me like it''s looking for /public/public/1/site.xml. I would try removing ''/public'' from the path. -andy -- Andrew Stone