# Can't get around this Routing Error

**URL:** <https://www.ruby-forum.com/t/cant-get-around-this-routing-error/169222>\
**Category:** Rails\
**Created:** [May 31, 2009, 11:45pm UTC](https://www.ruby-forum.com/t/cant-get-around-this-routing-error/169222 "2009-05-31T23:45:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jayco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c77e96/32.png) [@jayco](https://www.ruby-forum.com/u/jayco)\
**Post date:** [May 31, 2009, 11:45pm UTC](https://www.ruby-forum.com/t/cant-get-around-this-routing-error/169222/1 "2009-05-31T23:45:31Z")

</div>

Hi All,

I’m currently stuck trying to get a scaffold routed correctly. The line  
of code causing me problems is:

(link\_to ‘Edit’, edit\_listhub\_path(@listhub))

It works fine in 127.0.0.1:3000/listhubs.

However, when I try it in a partial in the “user” controller  
(127.0.0.1:3000/user,

I receive the error below:

* * *

ActionController::RoutingError in User#index

## edit\_listhub\_url failed to generate from {:action=\>“edit”, :controller=\>“listhubs”, :id=\>nil}, expected: {:action=\>“edit”, :controller=\>“listhubs”}, diff: {:id=\>nil}

My routes.rb file:

* * *

ActionController::Routing::Routes.draw do |map|  
map.resources :listhubs

map.resources :blogs do |blog|  
blog.resources :posts do |post|  
post.resources :comments  
end  
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 =\> ‘site’, :action =\> ‘index’, :id =\> nil

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

# instead of a file named ‘wsdl’

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

# Named routes.

map.hub ‘user’, :controller =\> ‘user’, :action =\> ‘index’  
map.profile ‘profile/:screen\_name’, :controller =\> ‘profile’, :action  
=\> ‘show’

# REST resources.

map.resources :specs

# Install the default route as the lowest priority.

## map.connect ‘:controller/:action/:id’ map.connect ‘:controller/:action/:id.:format’ end

Note: I can get my data to display fine, but my “edit” link give me this  
routing error.  
Is there something that needs to be altered in the partial and  
routes.rb? Thanks for your help.

---

<div class="post-metadata">

**Author:** ![jayco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c77e96/32.png) [@jayco](https://www.ruby-forum.com/u/jayco)\
**Post date:** [June 1, 2009, 12:37am UTC](https://www.ruby-forum.com/t/cant-get-around-this-routing-error/169222/2 "2009-06-01T00:37:47Z")

</div>

On May 31, 10:45 pm, Jay C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> (127.0.0.1:3000/user,
> 
> I receive the error below:
> 
> * * *
> 
> ActionController::RoutingError in User#index
> 
> edit\_listhub\_url failed to generate from {:action=\>“edit”,  
> :controller=\>“listhubs”, :id=\>nil}, expected: {:action=\>“edit”,  
> :controller=\>“listhubs”}, diff: {:id=\>nil}

This looks suspicious - is @listhub non nil in the case where you are  
rendering this partial ?

Fred

---

<div class="post-metadata">

**Author:** ![jayco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c77e96/32.png) [@jayco](https://www.ruby-forum.com/u/jayco)\
**Post date:** [June 1, 2009, 12:03pm UTC](https://www.ruby-forum.com/t/cant-get-around-this-routing-error/169222/3 "2009-06-01T12:03:36Z")

</div>

What does the partial contain? have u given @listhub any value for  
this action that its failing in?

On Jun 1, 3:37 am, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![jayco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c77e96/32.png) [@jayco](https://www.ruby-forum.com/u/jayco)\
**Post date:** [June 1, 2009, 1:27pm UTC](https://www.ruby-forum.com/t/cant-get-around-this-routing-error/169222/4 "2009-06-01T13:27:02Z")

</div>

Frederick C. wrote:

> On May 31, 10:45ï¿½pm, Jay C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> wrote:
> 
> > (127.0.0.1:3000/user,
> > 
> > I receive the error below:
> > 
> > * * *
> > 
> > ActionController::RoutingError in User#index
> > 
> > edit\_listhub\_url failed to generate from {:action=\>“edit”,  
> > :controller=\>“listhubs”, :id=\>nil}, expected: {:action=\>“edit”,  
> > :controller=\>“listhubs”}, diff: {:id=\>nil}
> 
> This looks suspicious - is @listhub non nil in the case where you are  
> rendering this partial ?
> 
> Fred

Yea, for some reason I erroneously added “@” to @listhub and was too  
tired to see it. The removal of this worked fine. Thanks!
