# Hiding URL params

**URL:** <https://www.ruby-forum.com/t/hiding-url-params/153222>\
**Category:** Rails\
**Created:** [November 13, 2008, 4:59pm UTC](https://www.ruby-forum.com/t/hiding-url-params/153222 "2008-11-13T16:59:20Z")\
**Posts on this page:** 5\
**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 13, 2008, 4:59pm UTC](https://www.ruby-forum.com/t/hiding-url-params/153222/1 "2008-11-13T16:59:20Z")

</div>

Hello,

How can I hide params on the URL? If I have the following resources,  
how can I hide the groups resources on the URL when showing posts?

map.resources :groups do |groups|  
groups.resources :posts  
end

Normally it will be groups/1/posts/1

I want the URL to show only posts/1 and have the group\_id and  
controller\_name invisible.

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 13, 2008, 5:31pm UTC](https://www.ruby-forum.com/t/hiding-url-params/153222/2 "2008-11-13T17:31:37Z")

</div>

then don’t nest the resources

map.resources :groups  
map.resources :posts

---

<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 13, 2008, 5:40pm UTC](https://www.ruby-forum.com/t/hiding-url-params/153222/3 "2008-11-13T17:40:24Z")

</div>

Hi Jemminger,

The thing is that I need that group\_id to perform some queries on the  
posts\_controller.

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 13, 2008, 9:31pm UTC](https://www.ruby-forum.com/t/hiding-url-params/153222/4 "2008-11-13T21:31:43Z")

</div>

Well, Long Version of the problem:

I know that is impossible unless I have a session or maybe sending an  
extra param at the end of the url. The app I am creating is built  
around the concept of groups. So a user can belong to various groups  
and make posts and events on each of them. They also want the users  
profiles to stand-alone on the URL without the group preceding. So a  
user profile will show all his/her activity on all the groups. But  
then, If I am navigating through a group and click on a user who  
created and event I will be taken to he/she’s profile and all the menu  
links for group events and posts will be broken because those links  
where created with the group\_id. So now I there’s no reference to  
which group I was navigating. That’s why I asked if maybe I could have  
it there but hidden.

---

<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 13, 2008, 11:24pm UTC](https://www.ruby-forum.com/t/hiding-url-params/153222/5 "2008-11-13T23:24:26Z")

</div>

if your Post belongs\_to a Group, then you can reference by  
@post.group\_id
