Hi all -
Here's my situation. We have a model Foo. All is well. Time for some SEO which gives us this as a route/url:
/foos/:id -> /foos/123-acme-foo
Easy to do by defining Foo.to_param. All is well. Time for some more SEO with this route/url:
/foos/:state/:city/:id -> /foos/wa/olympia/123-acme-foo
And now I lose the convenience of being able to do:
<%= link_to 'click', foo_path(@foo) %>
As it no longer recognizes the route. So I've resorted to defining a Foo.url_params which returns a hash containing the appropriate values and then do this:
<%= link_to 'click', foo_path(@foo.url_params) %>
It works, but I'm annoyed.
I guess what I'm kind of looking for is a to_params() method which if it exists will be used *instead* of to_param().
Or is there another way that will let me get back to doing foo_path(@foo) and have the route match?