# Changing routes

**URL:** <https://www.ruby-forum.com/t/changing-routes/152833>\
**Category:** Rails\
**Created:** [November 7, 2008, 9:55pm UTC](https://www.ruby-forum.com/t/changing-routes/152833 "2008-11-07T21:55:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![elioncho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ed8c4c/32.png) [@elioncho](https://www.ruby-forum.com/u/elioncho)\
**Post date:** [November 7, 2008, 9:55pm UTC](https://www.ruby-forum.com/t/changing-routes/152833/1 "2008-11-07T21:55:39Z")

</div>

Hello,

Well I am working on an app and wanted to make some changes on the  
URL’s. I have the following:

#—  
map.resources :groups do |groups|  
groups.resources :events, :member =\> { :invite =\> :get }  
end  
#—

So my events are mapping into:

#—

> **[XXX Sex - Free Porn Videos at XXX.com](https://www.xxx.com)**
>
> XXX Sex Videos - Free Porn Movies at XXX.com

#—

What I want to do now is take out the ‘group’ from there and only  
leave the id. Make it look like this:

#—

> **[XXX Sex - Free Porn Videos at XXX.com](https://www.xxx.com)**
>
> XXX Sex Videos - Free Porn Movies at XXX.com

#—

I tried something like the following and now I have an events\_path  
route that works.

#—  
map.events ‘:group\_id/events’, :controller =\> ‘events’, :action =\>  
‘index’  
#—

My question is: Should I then repeat this same line 5 times to map all  
the other actions? That without counting the member actions?

map.events\_new …  
map.events\_create…  
…  
…

It just seems wrong and tedious. It’s there any other way to do this?

Thanks for your attention,

Elías

---

<div class="post-metadata">

**Author:** ![elioncho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ed8c4c/32.png) [@elioncho](https://www.ruby-forum.com/u/elioncho)\
**Post date:** [November 8, 2008, 5:35pm UTC](https://www.ruby-forum.com/t/changing-routes/152833/2 "2008-11-08T17:35:42Z")

</div>

Hello,

Any ideas, or is this not a very bright idea after all?

Thanks,

Elioncho

---

<div class="post-metadata">

**Author:** ![elioncho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ed8c4c/32.png) [@elioncho](https://www.ruby-forum.com/u/elioncho)\
**Post date:** [November 10, 2008, 4:44pm UTC](https://www.ruby-forum.com/t/changing-routes/152833/3 "2008-11-10T16:44:40Z")

</div>

Hmmm I am not pretty sure, but try checking the path\_prefix and  
name\_prefix methods.

---

<div class="post-metadata">

**Author:** ![elioncho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ed8c4c/32.png) [@elioncho](https://www.ruby-forum.com/u/elioncho)\
**Post date:** [November 10, 2008, 5:25pm UTC](https://www.ruby-forum.com/t/changing-routes/152833/4 "2008-11-10T17:25:49Z")

</div>

Hello,

Well I tried those methods, but that doesn’t solve the problem. It  
seems to me that when using map.resources there’s no way of taking the  
controller name out of there. I think the only way is mapping each  
routes independently, which I don’t and that will get long.

Thanks,

Elías

---

<div class="post-metadata">

**Author:** ![elioncho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ed8c4c/32.png) [@elioncho](https://www.ruby-forum.com/u/elioncho)\
**Post date:** [November 11, 2008, 8:59pm UTC](https://www.ruby-forum.com/t/changing-routes/152833/5 "2008-11-11T20:59:03Z")

</div>

So, path\_prefix indeed worked.

You can use:

map.resources :events, :path\_prefix =\> ‘/:group\_id’

and it works! Just in case, anyone encounters this in the future.

---

<div class="post-metadata">

**Author:** ![elioncho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ed8c4c/32.png) [@elioncho](https://www.ruby-forum.com/u/elioncho)\
**Post date:** [November 10, 2008, 5:27pm UTC](https://www.ruby-forum.com/t/changing-routes/152833/6 "2008-11-10T17:27:37Z")

</div>

Hmmm, what I was trying to say in my last sentence is that mapping  
every route independently will be a tedious task.
