Forum: Ruby on Rails Can't get around this Routing Error

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.
Ee155fa576f53fca76097f1c6b29c960?d=identicon&s=25 Jay Covington (jcovington1)
on 2009-05-31 23:45
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.
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-06-01 00:37
(Received via mailing list)
On May 31, 10:45 pm, Jay Covington <rails-mailing-l...@andreas-s.net>
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
2dddec0f7717cae77ac6bceede6be5bc?d=identicon&s=25 Ram (Guest)
on 2009-06-01 12:03
(Received via mailing list)
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 Cheung <frederick.che...@gmail.com>
Ee155fa576f53fca76097f1c6b29c960?d=identicon&s=25 Jay Covington (jcovington1)
on 2009-06-01 13:27
Frederick Cheung wrote:
> On May 31, 10:45�pm, Jay Covington <rails-mailing-l...@andreas-s.net>
> 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!
This topic is locked and can not be replied to.