I am trying to follow answer to question
How to get link_to in Rails output an SEO friendly url?
but don\'t get the result. In my Rails 3 app I have:
Your link_to
will be using the route from resources :articles
. If you want it to use the custom route you've defined, name the route, and then use that in your link_to
:
# routes.rb
match '/articles/:id/:title' => 'articles#show', :as => :article_with_title
# articles/index.html.erb
link_to article.title, article_with_title_path(article, :title => article.title)
Also, you may want to consider looking into using friendly_id. It does this for you, but more transparently.