# Pretty urls with to\_param and rails sweepers problem

**URL:** <https://www.ruby-forum.com/t/pretty-urls-with-to-param-and-rails-sweepers-problem/92002>\
**Category:** Rails\
**Created:** [April 14, 2007, 7:44am UTC](https://www.ruby-forum.com/t/pretty-urls-with-to-param-and-rails-sweepers-problem/92002 "2007-04-14T07:44:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ingoweiss](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/77aa72/32.png) [@ingoweiss](https://www.ruby-forum.com/u/ingoweiss)\
**Post date:** [April 14, 2007, 7:44am UTC](https://www.ruby-forum.com/t/pretty-urls-with-to-param-and-rails-sweepers-problem/92002/1 "2007-04-14T07:44:36Z")

</div>

Hi all,

as seems to be quite common, I am overriding to\_param for some of my  
models to get nicer urls. For example:

countries/us/regions/ri

instead of

countries/15/regions/96

I understand the argument in favor of numeric ids, but in this case I am  
using ISO standard codes so I figured that should be OK even for the  
most puristic of purists.

It worked just fine for quite a while until I started using sweepers to  
clear my page cashes. Turns out that in contrast to url\_for, the sweeper  
constructs urls using the standard numeric ids instead of my custom  
ones, and hence fails to expire the pages correctly.

Is it possible to work around that somehow?

Ingo
