Forum: Ruby on Rails Hiding URL params

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Elias O. (Guest)
on 2008-11-13 17:59
(Received via mailing list)
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
Jeff E. (Guest)
on 2008-11-13 18:31
(Received via mailing list)
then don't nest the resources

map.resources :groups
map.resources :posts
Elias O. (Guest)
on 2008-11-13 18:40
(Received via mailing list)
Hi Jemminger,

The thing is that I need that group_id to perform some queries on the
posts_controller.

Elías
Elias O. (Guest)
on 2008-11-13 22:31
(Received via mailing list)
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.
Jeff E. (Guest)
on 2008-11-14 00:24
(Received via mailing list)
if your Post belongs_to a Group, then you can reference by
@post.group_id
This topic is locked and can not be replied to.