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

On Jun 19, 2:44 pm, Robin Fisher <[email protected]> wrote:
> On 19 June, 11:48, lecielbleu <[email protected]> wrote:
>
> > 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 
> > writehttp://domain/computer-componentsinsteadofhttp://domain/categories/53
>
> 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
--~--~---------~--~----~------------~-------~--~----~
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