On Mar 2, 2007, at 5:34 PM, Bertrand Mansion wrote:
> Le 2 mars 07 à 21:05, James Stewart a écrit :
>> On Mar 2, 2007, at 2:47 PM, Bertrand Mansion
wrote:
>>> Le 2 mars 07 à 19:18, James Stewart a écrit :
>>>> On Mar 2, 2007, at 1:02 PM, Bertrand
Mansion wrote:
>>>>> In Rails and ZF and others, the router
object is indeed
>>>>> routing: it takes the url and
automatically deduces a
>>>>> 'controller' and an 'action', even if
they were not defined in
>>>>> the url, then perform the action within
the controller. While
>>>>> this is handy if you have a framework
that was made to work
>>>>> this way, it's not very flexible
because there is a lot more
>>>>> you can do with an url than just
routing like this.
>>>>> Furthermore, in such frameworks, AFAIK
(but I might be wrong),
>>>>> you always end up with urls like these:
http://example.com/
>>>>> controller/action/arguments. This is
also a limitation IMO.
>>>>
>>>> I've not used ZF, but that's not the case
in rails. The default
>>>> route is
>>>>
>>>> map.connect ':controller/:action/:id'
>>>>
>>>> but that can be removed or replaced with a
wide variety of other
>>>> options. eg. One I often use in
location-driven sites is:
>>>>
>>>> map.connect 'zip/:id' , :controller =>
'locations', :action =>
>>>> 'zip'
>>> ^^^
>>> Just a question here, what is this map object
?
>>
>> In rails, that statement would be in your
config/routes.rb file
>> and would come inside a block, so the full
declaration would be:
>>
>>
>>
>> ActionController::Routing::Routes.draw do |map|
>>
>> map.connect 'zip/:id' , :controller =>
'locations', :action => 'zip'
>>
>> # Declare any other routes in here too
>>
>> end
>
> I figured that. I was just wondering why you named it
'map' and not
> router or routes ?
Cause that's the default Rails name in that context and I
didn't see
any reason to change it.
I guess DHH chose it because he's saying
_map_ this _route_ to these parameters.
The Rails dispatcher will then receive the parameters and
pass the
request to the specified controller.
James.
--
James Stewart
Play: http://james.ant
hropiccollective.org
Work: http://jystewart.net/pr
ocess/
|