Hi! I''m building a small CMS. If anyone''s interested, I can release it after I''m finished. However, I''m stuck and I need to be able to do two things: a) a Catch-all route: map.connect '':url'', :controller => ''contents'', :action => ''show'' However, that''s not possible because :url doesn''t catch any slashes, is that correct? Is there any way to make the Route catch slashes too? b) Feed a failed URL back into routing. E.g.: since every URL is routed to /contents/show, I need to be able to feed URLs that don''t map to any CMS-Content back into the Routing engine, so that some other Routing-Rule can catch it. I appreciate any help - Rob
You''re looking for the "catch-all" rule... ironic that you also called it that yourself :) Here''s an example: map.connect ''theme/*stuff'', :controller => ''theme'', :action => ''error'' The asterisk is what''s important. Anything after theme/ will be redirected to the theme_controller#error action. Duane Johnson (canadaduane) On Nov 7, 2005, at 11:31 AM, Robert wrote:> Hi! > > I''m building a small CMS. If anyone''s interested, I can release it > after I''m finished. > > However, I''m stuck and I need to be able to do two things: > > a) a Catch-all route: > map.connect '':url'', :controller => ''contents'', :action => ''show'' > > However, that''s not possible because :url doesn''t catch any slashes, > is that correct? Is there any way to make the Route catch slashes > too? > > b) Feed a failed URL back into routing. E.g.: since every URL is > routed to /contents/show, > I need to be able to feed URLs that don''t map to any CMS-Content > back into the Routing > engine, so that some other Routing-Rule can catch it. > > > > I appreciate any help > - Rob > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails
> You''re looking for the "catch-all" rule... ironic that you also > called it that yourself :)Thanks a bunch, that will do it :) That solved my first problem. Now regarding the "feeding back an url into the Routing Engine": I looked into the routing source code, but haven''t found anything that can do that. The most elegant solution would be to simply to: raise FailedRouting or something similar, to make Rails continue to match against the next rules. But for the time being I''ll just route my content pages to: /c/content_title Anyway, thanks alot! That helped :) Rob> > Here''s an example: > > map.connect ''theme/*stuff'', > :controller => ''theme'', :action => ''error'' > > The asterisk is what''s important. Anything after theme/ will be > redirected to the theme_controller#error action. > > Duane Johnson > (canadaduane) > > On Nov 7, 2005, at 11:31 AM, Robert wrote: > >> Hi! >> >> I''m building a small CMS. If anyone''s interested, I can release it >> after I''m finished. >> >> However, I''m stuck and I need to be able to do two things: >> >> a) a Catch-all route: >> map.connect '':url'', :controller => ''contents'', :action => ''show'' >> >> However, that''s not possible because :url doesn''t catch any slashes, >> is that correct? Is there any way to make the Route catch >> slashes too? >> >> b) Feed a failed URL back into routing. E.g.: since every URL is >> routed to /contents/show, >> I need to be able to feed URLs that don''t map to any CMS-Content >> back into the Routing >> engine, so that some other Routing-Rule can catch it. >> >> >> >> I appreciate any help >> - Rob >> _______________________________________________ >> 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 >
On 8.11.2005, at 0.10, Robert wrote:> >> You''re looking for the "catch-all" rule... ironic that you also >> called it that yourself :) > Thanks a bunch, that will do it :) > > > > That solved my first problem. Now regarding the "feeding back an > url into the Routing Engine": I looked into the routing source > code, but haven''t found anything that can do that. The most elegant > solution would be to simply to: > > raise FailedRouting > > or something similar, to make Rails continue to match against the > next rules. But for the time being I''ll just route my content pages > to: > > /c/content_titleYou can put that route as the last one and change existing routes so that they only match existing controllers. That way you can be sure that if a page is not found, it will not be found since you''re in the last route, and can display a 404. Not that elegant since you need to hard-code the ''legal'' controller names in at least one route, but it works. //jarkko> > > > Anyway, thanks alot! That helped :) > Rob > > > >> >> Here''s an example: >> >> map.connect ''theme/*stuff'', >> :controller => ''theme'', :action => ''error'' >> >> The asterisk is what''s important. Anything after theme/ will be >> redirected to the theme_controller#error action. >> >> Duane Johnson >> (canadaduane) >> >> On Nov 7, 2005, at 11:31 AM, Robert wrote: >> >>> Hi! >>> >>> I''m building a small CMS. If anyone''s interested, I can release >>> it after I''m finished. >>> >>> However, I''m stuck and I need to be able to do two things: >>> >>> a) a Catch-all route: >>> map.connect '':url'', :controller => ''contents'', :action => ''show'' >>> >>> However, that''s not possible because :url doesn''t catch any >>> slashes, >>> is that correct? Is there any way to make the Route catch >>> slashes too? >>> >>> b) Feed a failed URL back into routing. E.g.: since every URL is >>> routed to /contents/show, >>> I need to be able to feed URLs that don''t map to any CMS-Content >>> back into the Routing >>> engine, so that some other Routing-Rule can catch it. >>> >>> >>> >>> I appreciate any help >>> - Rob >>> _______________________________________________ >>> 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 >-- Jarkko Laine http://jlaine.net http://odesign.fi _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails