slavix
2011-Feb-05 21:29 UTC
[rspec-users] routing error for a name-spaced nested controller
Struggling with nested routing and rspec... When I run spec/controllers/admin/website_users_controller_spec.rb describe Admin::WebsiteUsersController do ... get :index, :website => @website at this line I get: ActionController::RoutingError Exception: No route matches {:website=>#<Website id: 1, name: "Website1">, :controller=>"admin/ website_users"} My routes.rb .. namespace :admin do resources :websites do resources :users, :controller => ''website_users'' end end rake routes ... admin_website_users GET /admin/websites/:website_id/ users(.:format) {:action=>"index", :controller=>"admin/ website_users"} thanks for help!
Mike Mazur
2011-Feb-08 00:02 UTC
[rspec-users] routing error for a name-spaced nested controller
Hi, On Sun, Feb 6, 2011 at 05:29, slavix <mikerin.slava at gmail.com> wrote:> Struggling with nested routing and rspec... > When I run spec/controllers/admin/website_users_controller_spec.rb > > describe Admin::WebsiteUsersController do > ... > get :index, :website => @websiteDoes that need to be: get :index, :website => @website.to_param HTH, Mike
Phillip Koebbe
2011-Feb-08 12:13 UTC
[rspec-users] routing error for a name-spaced nested controller
On 2011-02-05 3:29 PM, slavix wrote:> Struggling with nested routing and rspec... > When I run spec/controllers/admin/website_users_controller_spec.rb > > describe Admin::WebsiteUsersController do > ... > get :index, :website => @website > at this line I get: > > ActionController::RoutingError Exception: No route matches > {:website=>#<Website id: 1, name: "Website1">, :controller=>"admin/ > website_users"} > > My routes.rb > .. > namespace :admin do > resources :websites do > resources :users, :controller => ''website_users'' > end > end > >Just got up, so I may not be thinking clearly yet, but... If your users controller is nested inside a websites namespace, shouldn''t the spec be describe Admin::Websites::UsersController Check the controller itself and make sure the describe matches the class name. Peace. Phillip