只贴相关的
# routes.rb
namespace :admin do
resources :users
resources :projects
end
resources :projects do
resources :teams
end
rake routes
太长了,完整的去 pastebin 看,这里只写两条我认为相关的
# rake routes
admin_projects GET /admin/projects(.:format) admin/projects#index
projects GET /projects(.:format) projects#index
最后是 log
Started GET "/admin/projects" for 172.16.164.1 at 2012-04-28 14:32:22 +0800
Processing by ProjectsController#index as HTML
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = 3 LIMIT 1
Rendered layouts/_subnav.html.haml (4.8ms)
Project Load (0.3ms) SELECT "projects".* FROM "projects" ORDER BY updated_at DESC
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = 3 LIMIT 1
Rendered projects/_index.html.haml (120.0ms)
Rendered projects/index.html.haml within layouts/application (133.6ms)
Rendered layouts/_nav.html.haml (6.6ms)
Rendered layouts/_flash.html.haml (3.8ms)
Completed 200 OK in 353ms (Views: 256.2ms | ActiveRecord: 2.5ms)[2012-04-28 14:32:22] WARN Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true
问题是为什么我访问了 /admin/projects
却用了 projects#index
, 而不是 admin/projects#index