# Link\_to weirdness, related to namespace?

**URL:** <https://www.ruby-forum.com/t/link-to-weirdness-related-to-namespace/129679>\
**Category:** Rails\
**Created:** [February 20, 2008, 5:38pm UTC](https://www.ruby-forum.com/t/link-to-weirdness-related-to-namespace/129679 "2008-02-20T17:38:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 20, 2008, 5:38pm UTC](https://www.ruby-forum.com/t/link-to-weirdness-related-to-namespace/129679/1 "2008-02-20T17:38:43Z")

</div>

Hi,

In my app/views/admin/clieint/\_searchresults.rhtml partial, I have …

\<% for user in @users %\>

 \<%=h user.ship\_to\_first\_name %\> \<%=h user.ship\_to\_last\_name %\> \<%=h user.email %\> \<%= link\_to 'Show', {:action =\> 'show', :id =\> user.id} %\> \<% end %\>

but when the link is output to the browser, it is output as “/admin/  
client/2”, notice that the id is there, but the action, “show” is  
not. Why is link\_to not outputting correctly? I’m following the  
instructions from here –  
[ActionView::Helpers::UrlHelper](http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#M000913).  
Is it related to the “namespace” directive in my config;routes.rb  
file?

Thanks, - Dave

================begin config/routes.rb file =======================  
ActionController::Routing::Routes.draw do |map|

map.connect ‘’, :controller =\> “register”, :action =\> “start”

map.resources :users  
map.resources :sessions  
map.signup ‘/signup’, :controller =\> ‘users’, :action =\> ‘new’  
map.login ‘/login’, :controller =\> ‘sessions’, :action =\> ‘new’  
map.logout ‘/logout’, :controller =\> ‘sessions’, :action =\>  
‘destroy’  
map.change\_password ‘/change\_password’, :controller =\>  
‘user’, :action =\> ‘change\_password’

map.namespace :admin do |adm|  
adm.resources :client, :collection =\> { :search  
=\> :get, :searchresults =\> :get }  
end

# The priority is based upon order of creation: first created →

highest priority.

# Sample of regular route:

# map.connect ‘products/:id’, :controller =\> ‘catalog’, :action =\>

‘view’

# Keep in mind you can assign values other than :controller

and :action

# Sample of named route:

# map.purchase ‘products/:id/purchase’, :controller =\>

‘catalog’, :action =\> ‘purchase’

# This route can be invoked with purchase\_url(:id =\> product.id)

# You can have the root of your site routed by hooking up ‘’

# – just remember to delete public/index.html.

# map.connect ‘’, :controller =\> “welcome”

# Allow downloading Web Service WSDL as a file with an extension

# instead of a file named ‘wsdl’

map.connect ‘:controller/service.wsdl’, :action =\> ‘wsdl’

# Install the default route as the lowest priority.

# map.connect ‘:controller/:action/:id.:format’ map.connect ‘:controller/:action/:id’ end ====================end config/routes.rb file

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 20, 2008, 7:17pm UTC](https://www.ruby-forum.com/t/link-to-weirdness-related-to-namespace/129679/2 "2008-02-20T19:17:25Z")

</div>

I’d suggest removal of every route you don’t need, at least last three  
ones, but your problem is not there.  
In fact, there is no problem - link\_to creates exactly what you need -  
GET /admin/client/2 will be routed to Admin::ClientsController#show,  
as you would expect.  
Read more on all that restful stuff.

On 20 ÆÅ×, 18:37, “removed\_email\_address@domain.invalid”
