Ed W
2006-Jul-07 11:46 UTC
[Rails] How do URL''s like /images/xx get mapped to the correct place?
In the default routing file there is nothing about the /images/ URL, or the /javascript/ urls. ...So where is the code which makes these special URLs work? Cheers Ed W
Brian Hogan
2006-Jul-07 14:31 UTC
[Rails] How do URL''s like /images/xx get mapped to the correct place?
There is no code needed to make these work, as all requests look in the public folder first. If nothing is found (404), then the request goes through Rails. On 7/7/06, Ed W <lists@wildgooses.com> wrote:> > In the default routing file there is nothing about the /images/ URL, or > the /javascript/ urls. > > ...So where is the code which makes these special URLs work? > > Cheers > > Ed W > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060707/9c0f8064/attachment.html
Andrew Hodgkinson
2006-Jul-07 15:53 UTC
[Rails] Re: How do URL''s like /images/xx get mapped to the correct p
Brian Hogan wrote:> If nothing is found (404), then the request goes through Rails.Actually that kind of depends upon how your Web server is configured. You''re quite right that there''s nothing particularly special about the URLs, though.> > ...So where is the code which makes these special URLs work?Some people configure their Web server so that the Rails application''s "public" folder is the document root for the Web; then "/images/..." works just like any conventional URL, fetching a file from that document root. In such a case it often makes sense, if the Web server supports it, to have a "not found" document set up that''s actually one of the Rails dispatch.xyz files. Then things work exactly as Brian said. Other people put their Rails application somewhere outside the document root for the Web server, often for security reasons. It''s common to create a symbolic link in the Web server part of the filesystem to the Rails ''public'' directory in such a case. The use of a "not found" handler to run the Rails dispatcher may still apply; or in some cases, using URL rewriting to get the dispatcher to execute can be useful. Rails applications'' config/routes.rb files help reduce or eliminate the need for URL rewriting once the application is running, but they don''t eliminate the need for it (sometimes) to get the dispatcher kicked off in the first place, be it FastCGI or ''slow'' CGI. A more complex case occurs when you want a Rails application to exist away from the document root, in a subdirectory. Perhaps you want more than one Rails application running at once in one single domain - you''re unable or unwilling to put each one under a virtual domain. In this case the connections between Rails URLs, image URLs etc. and physical file locations can get quite abstract but funamdentally the same basic approaches of symbolic linking, Not Found handlers or rewriting seem to underpin the majority of installations. -- Posted via http://www.ruby-forum.com/.
Ed W
2006-Jul-07 17:29 UTC
[Rails] Re: How do URL''s like /images/xx get mapped to the correct p
Hi> Actually that kind of depends upon how your Web server is configured. > You''re quite right that there''s nothing particularly special about the > URLs, though. >... Aha, I see. That makes more sense now. Cheers Ed W
Maybe Matching Threads
- fwd: [syslinux:syslinux-4.xx] mbr/isohdpfx.S: correct stack for heads/sectors
- Good Package(s) for String and URL processing?
- [Fwd: Re: /sbin/tc does not know about HTB]
- routes question [Catching URL in a variable]
- HTB is nor fair when ''borrowing? Can someone correct me or maybe Devik''s HTB has a bug?