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. -- Posted via http://www.ruby-forum.com/.
On May 31, 10:45 pm, Jay Covington <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> 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}This looks suspicious - is @listhub non nil in the case where you are rendering this partial ? Fred
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...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On May 31, 10:45 pm, Jay Covington <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: > > > > > 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} > > This looks suspicious - is @listhub non nil in the case where you are > rendering this partial ? > > Fred
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 ? > > FredYea, for some reason I erroneously added "@" to @listhub and was too tired to see it. The removal of this worked fine. Thanks! -- Posted via http://www.ruby-forum.com/.