# Using variable in :path\_prefix

**URL:** <https://www.ruby-forum.com/t/using-variable-in-path-prefix/106413>\
**Category:** Rails\
**Created:** [June 10, 2007, 3:33am UTC](https://www.ruby-forum.com/t/using-variable-in-path-prefix/106413 "2007-06-10T03:33:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tarscher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/8491ac/32.png) [@Tarscher](https://www.ruby-forum.com/u/Tarscher)\
**Post date:** [June 10, 2007, 3:33am UTC](https://www.ruby-forum.com/t/using-variable-in-path-prefix/106413/1 "2007-06-10T03:33:23Z")

</div>

Hi all,

I have a couple of restful controller. I use path\_prefix to add a  
string to the path.

I have a club controller and model and it’s the club id I want in  
the :path\_prefix

in my routes I have:  
map.resources :clubs  
map.resources :users, :path\_prefix =\> :club  
map.resources :posts, :path\_prefix =\> :club  
map.resources :user, :path\_prefix =\> :club  
map.connect ‘:club/’, :controller =\> ‘club’, :action =\> ‘index’  
map.connect ‘:club/:controller/:action/:id’  
map.connect ‘:controller/service.wsdl’, :action =\> ‘wsdl’

I read the :club parameter in in application controller. Everytime a  
user enters a url I thus set the club id eg. [www.domain.com/zero/posts](http://www.domain.com/zero/posts)  
sets the club id to zero.

When I use new\_post\_path I don’t get [www.domain.com/zero/posts/new](http://www.domain.com/zero/posts/new) but  
[www.domain.com/club/posts/new](http://www.domain.com/club/posts/new)

Someone has an idea what I do wrong?

Regards,  
Stijn
