hi guys, I have a resource, "parts". Another resource, "fits" relates to "parts". config/routes.rb --------------------- ActionController::Routing::Routes.draw do |map| map.resources :parts, :has_many => :image map.resources :parts, :has_many => :fits ... map.connect ''get_vehicles'', :controller => "parts" , :action => ''get_vehicles'' map.connect ''get_subcategories'', :controller => "parts" , :action => ''get_subcategories'' map.root :controller => "home" end running rake routes gives the output below: ================================ parts GET /parts (.:format) {:action=>"index", :controller=>"parts"} POST /parts (.:format) {:action=>"create", :controller=>"parts"} new_part GET /parts/new (.:format) {:action=>"new", :controller=>"parts"} edit_part GET /parts/:id/edit (.:format) {:action=>"edit", :controller=>"parts"} part GET /parts/:id (.:format) {:action=>"show", :controller=>"parts"} PUT /parts/:id (.:format) {:action=>"update", :controller=>"parts"} DELETE /parts/:id (.:format) {:action=>"destroy", :controller=>"parts"} part_fits GET /parts/:part_id/fits (.:format) {:action=>"index", :controller=>"fits"} POST /parts/:part_id/fits (.:format) {:action=>"create", :controller=>"fits"} new_part_fit GET /parts/:part_id/fits/new (.:format) {:action=>"new", :controller=>"fits"} edit_part_fit GET /parts/:part_id/fits/:id/edit (.:format) {:action=>"edit", :controller=>"fits"} part_fit GET /parts/:part_id/fits/:id (.:format) {:action=>"show", :controller=>"fits"} PUT /parts/:part_id/fits/:id (.:format) {:action=>"update", :controller=>"fits"} DELETE /parts/:part_id/fits/:id (.:format) {:action=>"destroy", :controller=>"fits"} POST / get_vehicles {:action=>"get_vehicles", :controller=>"fits"} ... Showing all Routes ... - /get_subcategories/ ... Controller: controllers/parts_controller.erb (extract) ------------------------------------------------ ... def get_vehicles @make = Make.find(params [:make_id]) @vehicles @make.vehicles.all; end ... When i access "http://localhost:3000/parts/2/fits/new" which runs a partial which uses get_vehicles, I run into this error of "No route matches {:action=>"get_vehicles"}". My other resources work without problem with the same set up but with a nested setup (ie. parts/<parts id>/fits/), rails'' routing doesn''t work as expected. Has anyone come across this problem? For the moment, I moved def get_vehicles into the fits_controller.erb but i would still like to find out how to keep def get_vehicles in the parts_controller.erb... thanks :)
Can you post the full stacktrace? My guess is you have a reference to get_vehicles that is causing the problem. The nested routes look like they are working. However, it''s hard to determine based on the information provided. Darian Shimy -- http:/www.darianshimy.com http://twitter.com/dshimy On Mon, Nov 16, 2009 at 3:24 AM, ct9a <anexiole-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > hi guys, > > I have a resource, "parts". Another resource, "fits" relates to > "parts". > > config/routes.rb > --------------------- > > > ActionController::Routing::Routes.draw do |map| > map.resources :parts, :has_many => :image > map.resources :parts, :has_many => :fits > ... > map.connect ''get_vehicles'', :controller => "parts" , :action => > ''get_vehicles'' > map.connect ''get_subcategories'', :controller => "parts" , :action => > ''get_subcategories'' > > map.root :controller => "home" > end > > > running rake routes gives the output below: > ================================> > parts GET /parts > (.:format) > {:action=>"index", :controller=>"parts"} > POST /parts > (.:format) > {:action=>"create", :controller=>"parts"} > new_part GET /parts/new > (.:format) > {:action=>"new", :controller=>"parts"} > edit_part GET /parts/:id/edit > (.:format) > {:action=>"edit", :controller=>"parts"} > part GET /parts/:id > (.:format) > {:action=>"show", :controller=>"parts"} > PUT /parts/:id > (.:format) > {:action=>"update", :controller=>"parts"} > DELETE /parts/:id > (.:format) > {:action=>"destroy", :controller=>"parts"} > part_fits GET /parts/:part_id/fits > (.:format) > {:action=>"index", :controller=>"fits"} > POST /parts/:part_id/fits > (.:format) > {:action=>"create", :controller=>"fits"} > new_part_fit GET /parts/:part_id/fits/new > (.:format) > {:action=>"new", :controller=>"fits"} > edit_part_fit GET /parts/:part_id/fits/:id/edit > (.:format) {:action=>"edit", :controller=>"fits"} > part_fit GET /parts/:part_id/fits/:id > (.:format) > {:action=>"show", :controller=>"fits"} > PUT /parts/:part_id/fits/:id > (.:format) > {:action=>"update", :controller=>"fits"} > DELETE /parts/:part_id/fits/:id > (.:format) > {:action=>"destroy", :controller=>"fits"} > > POST / > get_vehicles > {:action=>"get_vehicles", :controller=>"fits"} > ... > > Showing all Routes > ... > - /get_subcategories/ > ... > > Controller: controllers/parts_controller.erb (extract) > ------------------------------------------------ > ... > def get_vehicles > @make = Make.find(params > [:make_id]) > @vehicles > @make.vehicles.all; > > end > ... > > > > > > > When i access "http://localhost:3000/parts/2/fits/new" which runs a > partial which uses get_vehicles, > I run into this error of "No route matches {:action=>"get_vehicles"}". > > My other resources work without problem with the same set up but with > a nested setup (ie. parts/<parts id>/fits/), rails'' routing doesn''t > work as expected. > > Has anyone come across this problem? > > For the moment, I moved def get_vehicles into the fits_controller.erb > but i would still like to find out how to keep def get_vehicles in the > parts_controller.erb... > > > thanks :) > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Nov 16, 3:24 am, ct9a <anexi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> map.resources :parts, :has_many => :image > map.resources :parts, :has_many => :fitsThis doesn''t answer your question directly, but the canonical way to do multiple nestings is with a block: map.resources :parts do |parts| parts.resources :image parts.resources :fits end
good morning, scott, yep, i somehow got passed that. I believed that it was because 1) i ran "rake routes " 2) and realised that i did not provide a @part object. thank you :) 2009/11/18 Scott Johnson <scott-wIW8SF+lElu2kH9Ulgv/9g@public.gmane.org>> > > > On Nov 16, 3:24 am, ct9a <anexi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > map.resources :parts, :has_many => :image > > map.resources :parts, :has_many => :fits > > This doesn''t answer your question directly, but the canonical way to > do multiple nestings is with a block: > > map.resources :parts do |parts| > parts.resources :image > parts.resources :fits > end > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---