On 20 August 2010 13:23, Abder-Rahman Ali <[email protected]> wrote:
> In the "Head First Rails" book, it mentions this ordering in routes.rb:
>
> ActionController: : Routing: : Routes. draw do | map|
>   map. connect ' /ads/new' , : controller=>' ads' , : action=>' new'
>   map. connect ' /ads/create' , : controller=>' ads' , : action=>'
> create'
>   map. connect ' /ads/' , : controller=>' ads' , : action=>' index'
>   map. connect ' /ads/: id' , : controller=>' ads' , : action=>' show'
>
> If we enter:
>
>   map. connect ' /ads/: id' , : controller=>' ads' , : action=>' show'
>
> At the top of the ordering, how will that affect our routing.
>
> Can you just describe how to order routes in routes.rb? I mean, what is
> the rule to follow when ordering routes?

The first entry in the file that matches is used, later ones are
disregarded, so if you put the /ads/:id one at the start (note there
is no space after the colon), then if a url matches that route then
later ones will not be tested.  You can always try it and see for
yourself what happens.  Have a look at the Rails Guide on routing for
more information.

Colin

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to