Hi, I have the following routing line that isn''t working: Map.connect "/maintenace/:controller/:action/:building_id/:room_id, :building_id => /\d+/, :room_id =>/\d+/ So for example I want www.domain.com/maintenance/category/23/45/ To be interpreted as: directory: "maintenance", controller: "category", building_id: "23", room_id: "24". Keep in mind that there is more than one controller in the maintenance folder that should behave the same way. What''s wrong with the code? SB
It looks like you are missing the :action part of the url in www.domain.com/maintenance/category/*action*/23/45 you can either change your request url to include this: www.domain.com/maintenance/category/some_action/23/45 OR you can set a default action by changing your route to: map.connect "maintenace/:controller/:building_id/:room_id", :action => ''some_action'', :building_id => /\d+/, :room_id =>/\d+/ On 9/22/05, Sergio Bayona <sergio-SZhfuDltjDxEfCMKe0UOsQC/G2K4zDHf@public.gmane.org> wrote:> Hi, > > I have the following routing line that isn''t working: > > Map.connect "/maintenace/:controller/:action/:building_id/:room_id, > :building_id => /\d+/, > :room_id =>/\d+/ > > > So for example I want www.domain.com/maintenance/category/23/45/ > To be interpreted as: directory: "maintenance", controller: "category", > building_id: "23", room_id: "24". Keep in mind that there is more than one > controller in the maintenance folder that should behave the same way. > > What''s wrong with the code? > > SB > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
sergio-SZhfuDltjDxEfCMKe0UOsQC/G2K4zDHf@public.gmane.org
2005-Sep-23 06:25 UTC
Re: Routing question
well, the goal is to allow any action on any controller that''s in the "maintenance" folder to take :building_id and :room_id as parameters.> It looks like you are missing the :action part of the url in > www.domain.com/maintenance/category/*action*/23/45 > > you can either change your request url to include this: > www.domain.com/maintenance/category/some_action/23/45 > OR > you can set a default action by changing your route to: > map.connect "maintenace/:controller/:building_id/:room_id", > :action => ''some_action'', > :building_id => /\d+/, > :room_id =>/\d+/ > > > On 9/22/05, Sergio Bayona <sergio-SZhfuDltjDxEfCMKe0UOsQC/G2K4zDHf@public.gmane.org> wrote: >> Hi, >> >> I have the following routing line that isn''t working: >> >> Map.connect "/maintenace/:controller/:action/:building_id/:room_id, >> :building_id => /\d+/, >> :room_id =>/\d+/ >> >> >> So for example I want www.domain.com/maintenance/category/23/45/ >> To be interpreted as: directory: "maintenance", controller: "category", >> building_id: "23", room_id: "24". Keep in mind that there is more than >> one >> controller in the maintenance folder that should behave the same way. >> >> What''s wrong with the code? >> >> SB >> >> >> _______________________________________________ >> 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 >
You would then probably want to go with the first suggestion and put the action in your link/url. Otherwise rails doesn''t know which method of the controller you are calling. for example: www.domain.com/maintenance/category/some_action/23/45 www.domain.com/maintenance/category/another_action/23/45 should work with this route: map.connect "maintenace/:controller/:action/:building_id/:room_id", :building_id => /\d+/, :room_id =>/\d+/ On 9/22/05, sergio-SZhfuDltjDxEfCMKe0UOsQC/G2K4zDHf@public.gmane.org <sergio-SZhfuDltjDxEfCMKe0UOsQC/G2K4zDHf@public.gmane.org> wrote:> well, the goal is to allow any action on any controller that''s in the > "maintenance" folder to take :building_id and :room_id as parameters. > > > > It looks like you are missing the :action part of the url in > > www.domain.com/maintenance/category/*action*/23/45 > > > > you can either change your request url to include this: > > www.domain.com/maintenance/category/some_action/23/45 > > OR > > you can set a default action by changing your route to: > > map.connect "maintenace/:controller/:building_id/:room_id", > > :action => ''some_action'', > > :building_id => /\d+/, > > :room_id =>/\d+/ > > > > > > On 9/22/05, Sergio Bayona <sergio-SZhfuDltjDxEfCMKe0UOsQC/G2K4zDHf@public.gmane.org> wrote: > >> Hi, > >> > >> I have the following routing line that isn''t working: > >> > >> Map.connect "/maintenace/:controller/:action/:building_id/:room_id, > >> :building_id => /\d+/, > >> :room_id =>/\d+/ > >> > >> > >> So for example I want www.domain.com/maintenance/category/23/45/ > >> To be interpreted as: directory: "maintenance", controller: "category", > >> building_id: "23", room_id: "24". Keep in mind that there is more than > >> one > >> controller in the maintenance folder that should behave the same way. > >> > >> What''s wrong with the code? > >> > >> SB > >> > >> > >> _______________________________________________ > >> 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 >