I have a route like so:
map.resources :articles
And I need to be able to have a URL like:
/article/:id/:slug
Is there any way to do this without messing with view code? I’ve looked
around at route documentation and code but can’t wrap my head around it.
I know there’s the to_param way to get “id-slug” but I am porting my app
from PHP to Rails and really need to preserve my URLs.
Note Updated to Rails 2.1 as I needed to use a few things from there,
perhaps there are methods in 2.1 that could help with this?
Rails T. wrote:
And also this url :
http://www.urbanpuddle.com/articles/2007/03/05/restful-authentication-for-ruby-on-rails-apps

Reinhart
I don’t think either of those URL’s really answer my question?
The whole routing system leans on the to_param method of
ActiveRecord. With that in mind, I’d suggest trying to override
Article#to_param:
class Artice < ActiveRecord::Base
…
def to_param
“#{id}/#{slug}”
end
end
That way, the article will include both it’s id and slug when it’s
used to create a url. It’s a bit of a hack, but it might work.
On Jun 1, 6:17 pm, “Nathan W.” [email protected]
Andy, thanks for the help. I had tried that before but it actually
sanitizes the html for the url, so its something like
article/100%XXtitle-of-article
Nathan W. wrote:
Andy, thanks for the help. I had tried that before but it actually
sanitizes the html for the url, so its something like
article/100%XXtitle-of-article
You should read carefully my link because what Andi explained to you was
described in my link :
http://earthcode.com/blog/2007/01/to_param_still_works_with_rest.html

Reinhart
Right, I understand that technique and I wrote in my original post that
I specifically dont want to do that… Also your links above were
wrongly done…
Is there a way to update, say, article_path, to output this result with
the ‘/’?