# "-" instead of "\_" in routes?

**URL:** <https://www.ruby-forum.com/t/instead-of-in-routes/90793>\
**Category:** Rails\
**Created:** [April 1, 2007, 7:16pm UTC](https://www.ruby-forum.com/t/instead-of-in-routes/90793 "2007-04-01T19:16:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![josh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/45deac/32.png) [@josh](https://www.ruby-forum.com/u/josh)\
**Post date:** [April 1, 2007, 7:16pm UTC](https://www.ruby-forum.com/t/instead-of-in-routes/90793/1 "2007-04-01T19:16:34Z")

</div>

Hi all

I’d like to have minus signs “-” instead of underscores “\_” in my  
routes. Is there an easy to do that?

my\_controller/show\_something/123 # \<= not cool  
my-controller/show-something/123 # \<= much cooler

Thanks a lot  
Josh

---

<div class="post-metadata">

**Author:** ![josh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/45deac/32.png) [@josh](https://www.ruby-forum.com/u/josh)\
**Post date:** [April 1, 2007, 7:38pm UTC](https://www.ruby-forum.com/t/instead-of-in-routes/90793/2 "2007-04-01T19:38:12Z")

</div>

On 4/1/07, Joshua M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Josh  
> map.connect ‘foo-bar’, :controller =\> ‘foo\_bar’, :action =\> ‘index’

–  
Rick O.  
[http://lighthouseapp.com](http://lighthouseapp.com)  
[http://weblog.techno-weenie.net](http://weblog.techno-weenie.net)  
[http://mephistoblog.com](http://mephistoblog.com)

---

<div class="post-metadata">

**Author:** ![josh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/45deac/32.png) [@josh](https://www.ruby-forum.com/u/josh)\
**Post date:** [April 1, 2007, 7:38pm UTC](https://www.ruby-forum.com/t/instead-of-in-routes/90793/3 "2007-04-01T19:38:13Z")

</div>

On Sun, Apr 01, 2007 at 07:16:34PM +0200, Joshua M. wrote:

> Hi all
> 
> I’d like to have minus signs “-” instead of underscores “\_” in my  
> routes. Is there an easy to do that?
> 
> my\_controller/show\_something/123 # \<= not cool  
> my-controller/show-something/123 # \<= much cooler

Given that Rails is open source, the answer is certainly yes. You can  
monkey-patch the routing process to call #underscore (or just change  
hyphens to underscores) before calling #camelize on the URI path.  
Alternately, you can alter (monkey-patch) the #camelize method such that  
it  
deals with hyphens anyway, though that might have unforeseen  
consequences.

There is no built in way to do it as far as I know, however.

> Thanks a lot  
> Josh  
> –Greg
