display category name in url

Hi , do we have to use controller name in url , can we change this?
For example i have a controller named => category
when user click to link "Computer Components"
can rails write http://domain/computer-components instead of
http://domain/categories/53

map.computer_components 'computer_components',:controller =>
"categories",:action => "your_action_name'

   Now helper will be computer_components_url

Sijo

Hi,

This is possible by creating a custom route in routes.rb. You would
need to do the following:

map.connect '/:category_name', :controller => 'categories', :action =>
'show'

However, you need to be careful where this sits in your routes.rb as
it will catch every URL if it is too high in the file. In your
categories controller, the show action would need the following:

@category = Category.find_by_name(params[:category_name]

I should point out that this is not good practice and if you intend to
have a significant number of categories, the id should be used. The
following link shows how you can get 'friendly' urls whilst still
using standard Rails routing.

http://www.jroller.com/obie/entry/seo_optimization_of_urls_in

Regards

Robin

Many thanks Robin , yes it's possible doing this as you said but i
have too much categories and subcategories (using acts_as_tree) ,
Method i will use must be dynamic , if not i cant handle with
100categories