Filip Godsmurf
2006-Feb-28 22:15 UTC
[Rails] Can I let routes.rb take precedence over file names?
I''d like Rails to intercept the url''s of html pages in a certain directory so I can embed them in my site. I put them in public/pages and tried to catch them with a route like map.connect ''pages/:pagename'' However this only works if the file does not exist; e.g. "pages/test.html" will only be routed if that file doesn''t exist, otherwise it will just show the file. Is there any other way I can reroute url''s of existing html files? The reason I need to use the real directory and file names is that these html pages contain images and cross-links which still need to work. -- Posted via http://www.ruby-forum.com/.
Matthew Palmer
2006-Mar-01 06:46 UTC
[Rails] Re: Can I let routes.rb take precedence over file names?
On Tue, Feb 28, 2006 at 11:15:16PM +0100, Filip Godsmurf wrote:> I''d like Rails to intercept the url''s of html pages in a certain > directory so I can embed them in my site. I put them in public/pages and > tried to catch them with a route like > > map.connect ''pages/:pagename'' > > However this only works if the file does not exist; e.g. > "pages/test.html" will only be routed if that file doesn''t exist, > otherwise it will just show the file. > > Is there any other way I can reroute url''s of existing html files? > > The reason I need to use the real directory and file names is that these > html pages contain images and cross-links which still need to work.I don''t understand why you need to have the filenames still exist in public/pages. If you need to access their content, you can stick them somewhere else (out of public). I''d be very leery of having Rails handle every single request -- you''d need to add some sort of generic magic to serve out the static files, as once the webserver has handed control off to Rails, I don''t think Rails can throw back to the webserver and say "I don''t want this one, you take it". - Matt