我尝试将管理区域添加到我的网站。所以我添加了一个包含控制器“posts”和“category”的命名空间。在 routes.rb 文件中,我添加了
namespace :admin do
resources :posts , :categories
match '/' => 'posts#index', :via => :get
end
但使用网址:
myurl.com/admin
我有错误:
没有路由匹配 {:controller=>"admin/site", :action=>"home", :locale=>:fr}
似乎调用了另一条路线并覆盖了我添加的路线
但在耙式路线中,我有:
admin GET /admin(.:format) admin/posts#index
这里是完整的 rake 路线:
faq GET (/:locale)/faq(.:format) site#faq {:locale=>/[a-zA-Z]{2}/}
rules GET (/:locale)/rules(.:format) site#rules {:locale=>/[a-zA-Z]{2}/}
advanced_rules GET (/:locale)/advanced_rules(.:format) site#advanced_rules {:locale=>/[a-zA-Z]{2}/}
play_now GET (/:locale)/play_now(.:format) play#play {:locale=>/[a-zA-Z]{2}/}
play GET (/:locale)/play(.:format) site#play {:locale=>/[a-zA-Z]{2}/}
home GET (/:locale)/home(.:format) site#home {:locale=>/[a-zA-Z]{2}/}
GET (/:locale)/qrcode(/:code)(.:format) site#qrcode {:locale=>/[a-zA-Z]{2}/}
forgot_password GET (/:locale)/forgot_password/:id(.:format) passwords#forgot_password {:locale=>/[a-zA-Z]{2}/}
android_redirect GET (/:locale)/android_redirect(.:format) android#index {:locale=>/[a-zA-Z]{2}/}
general_conditions GET (/:locale)/general_conditions(.:format) site#general_conditions {:locale=>/[a-zA-Z]{2}/}
support GET (/:locale)/support(.:format) site#support {:locale=>/[a-zA-Z]{2}/}
GET (/:locale)/invitation(/:source)(.:format) invitation#redirection {:locale=>/[a-zA-Z]{2}/}
release_notes GET (/:locale)/release_notes(.:format) site#release_notes {:locale=>/[a-zA-Z]{2}/}
release_note GET (/:locale)/release_notes/:version(.:format) release_notes#show {:locale=>/[a-zA-Z]{2}/}
root GET /(:locale)(.:format) site#home {:locale=>/[a-zA-Z]{2}/}
admin_posts GET /admin/posts(.:format) admin/posts#index
POST /admin/posts(.:format) admin/posts#create
new_admin_post GET /admin/posts/new(.:format) admin/posts#new
edit_admin_post GET /admin/posts/:id/edit(.:format) admin/posts#edit
admin_post GET /admin/posts/:id(.:format) admin/posts#show
PUT /admin/posts/:id(.:format) admin/posts#update
DELETE /admin/posts/:id(.:format) admin/posts#destroy
admin_categories GET /admin/categories(.:format) admin/categories#index
POST /admin/categories(.:format) admin/categories#create
new_admin_category GET /admin/categories/new(.:format) admin/categories#new
edit_admin_category GET /admin/categories/:id/edit(.:format) admin/categories#edit
admin_category GET /admin/categories/:id(.:format) admin/categories#show
PUT /admin/categories/:id(.:format) admin/categories#update
DELETE /admin/categories/:id(.:format) admin/categories#destroy
admin GET /admin(.:format) admin/posts#index
completed GET /payment_completed(.:format) payment#completed
android GET /android(.:format) hockeyapps#android
login POST /login(.:format) registrations#login
loginfacebook POST /loginfacebook(.:format) registrations#loginfacebook
status GET /status(.:format) registrations#status
logout DELETE /logout(.:format) registrations#logout
geturl POST /geturl/:id/:token(.:format) paypals#geturl
getstatus POST /getstatus/:id/:token(.:format) paypals#getstatus
payment_completed GET /payment_completed(.:format) payment#completed
forgot_password GET /forgot_password/:id(.:format) passwords#forgot_password
send_password POST /send_password(.:format) passwords#send_password
这里是完整的文件 routes.rb:
scope "(:locale)", :constraints => {:locale => /[a-zA-Z]{2}/} do
match '/faq' => 'site#faq', :via => :get
match '/rules' => 'site#rules', :via => :get
match '/advanced_rules' => 'site#advanced_rules', :via => :get
match '/play_now' => 'play#play', :via => :get
match '/play' => 'site#play', :via => :get
match '/home' => 'site#home', :via => :get
match '/qrcode/(:code)' => 'site#qrcode', :via => :get
match '/forgot_password/:id' => 'passwords#forgot_password', :via => :get, :as => "forgot_password"
match '/android_redirect' => 'android#index', :via => :get, :as => "android_redirect"
match '/general_conditions' => "site#general_conditions", :via => :get
match '/support' => "site#support", :via => :get
match '/invitation/(:source)' => 'invitation#redirection', :via => :get
match '/release_notes' => 'site#release_notes', :via => :get, :as => "release_notes"
match '/release_notes/:version' => 'release_notes#show', :via => :get, :as => "release_note"
root :to => 'site#home', :via => :get
end
namespace :admin do
resources :posts , :categories
match '/' => 'posts#index', :via => :get
end
get 'payment_completed' => 'payment#completed', :as => "completed"
get 'android' => 'hockeyapps#android', :as => 'android'
post 'login' => 'registrations#login', :as => 'login'
post 'loginfacebook' => 'registrations#loginfacebook', :as => 'loginfacebook'
get 'status' => 'registrations#status', :as => 'status'
delete 'logout' => 'registrations#logout', :as => 'logout'
post 'geturl/:id/:token' => 'paypals#geturl', :as => 'geturl'
post 'getstatus/:id/:token' => 'paypals#getstatus', :as => 'getstatus'
get 'payment_completed' => 'payment#completed', :as => 'payment_completed'
#scope :protocol => 'https://', :constraints => { :protocol => 'https://' } do
# resources :passwords
#end
get 'forgot_password/:id' => 'passwords#forgot_password', :as => 'forgot_password'
post 'send_password' => 'passwords#send_password', :as => 'send_password'
end
关于这个问题的任何想法?
谢谢