在生产服务器上设计 404 错误,没有路由匹配 :controller=>"devise/home"
Posted
技术标签:
【中文标题】在生产服务器上设计 404 错误,没有路由匹配 :controller=>"devise/home"【英文标题】:Devise 404 errors on production server, No route matches :controller=>"devise/home"在生产服务器上设计 404 错误,没有路由匹配 :controller=>"devise/home" 【发布时间】:2012-07-10 14:29:32 【问题描述】:我在生产服务器上遇到了设计 404 错误,包括对 /users/sign_in 的获取请求及其“link_to”等价物。如果我将 development.rb 复制到 production.rb,则会收到错误消息:
没有路由匹配 :controller=>"devise/home"
这个:
在我的开发箱上工作。
不适用于使用 webbrick 或乘客的生产框。
所有其他路线都可以正常工作,但设计路线却不行。我想我已经阅读了所有可以找到的所有 *** 和其他 google-fu 链接,但到目前为止还没有运气。
“Rake routes”输出如下。如果我尝试 /users/sign_in GET 解析到的路由(即 devise/sessions#new),我会收到错误消息:No route matches [GET] "/devise/sessions"
以下都不起作用:
link_to('登录/注册', new_user_session_path) link_to('Login / Regsiter', :controller => "devise/sessions", :action => "new") link_to('Login / Regsiter', :controller => "/devise/sessions", :action => "new") link_to('登录/注册', '/users/sign_up')
我看到了一些关于范围界定问题的参考资料,但考虑到这些症状,如果这对我有任何意义,我会感到很遗憾。我完全被这个难住了。有什么想法吗?
routes.rb 内容和“rake routes”输出如下:
Aprojectx::Application.routes.draw do
devise_for :users
match "/people/test" => "people#test"
resources :people Aprojectx::Application.routes.draw do
devise_for :users
match "/people/test" => "people#test"
resources :people
resources :document_versions
resources :documents
resources :escrow_roles
resources :escrows
resources :tasks
root :to => 'home#index'
match "/specification" => 'home#specification'
match "/sales" => 'home#sales'
end
resources :document_versions
Aprojectx::Application.routes.draw do
devise_for :users
match "/people/test" => "people#test"
resources :people
resources :document_versions Aprojectx::Application.routes.draw do
devise_for :users
match "/people/test" => "people#test"
resources :people
resources :document_versions
resources :documents
resources :escrow_roles
resources :escrows
resources :tasks
root :to => 'home#index'
match "/specification" => 'home#specification'
match "/sales" => 'home#sales'
end
resources :documents
resources :escrow_roles
resources :escrows
resources :tasks
root :to => 'home#index'
match "/specification" => 'home#specification'
match "/sales" => 'home#sales'
end
resources :documents
resources :escrow_roles
resources :escrows
resources :tasks
root :to => 'home#index'
match "/specification" => 'home#specification'
match "/sales" => 'home#sales'
end
root@escrowmaker:/var/www/apps/aprojectx# rake routes
people_test /people/test(.:format) people#test
people GET /people(.:format) people#index
POST /people(.:format) people#create
new_person GET /people/new(.:format) people#new
edit_person GET /people/:id/edit(.:format) people#edit
person GET /people/:id(.:format) people#show
PUT /people/:id(.:format) people#update
DELETE /people/:id(.:format) people#destroy
document_versions GET /document_versions(.:format) document_versions#index
POST /document_versions(.:format) document_versions#create
new_document_version GET /document_versions/new(.:format) document_versions#new
edit_document_version GET /document_versions/:id/edit(.:format) document_versions#edit
document_version GET /document_versions/:id(.:format) document_versions#show
PUT /document_versions/:id(.:format) document_versions#update
DELETE /document_versions/:id(.:format) document_versions#destroy
documents GET /documents(.:format) documents#index
POST /documents(.:format) documents#create
new_document GET /documents/new(.:format) documents#new
edit_document GET /documents/:id/edit(.:format) documents#edit
document GET /documents/:id(.:format) documents#show
PUT /documents/:id(.:format) documents#update
DELETE /documents/:id(.:format) documents#destroy
escrow_roles GET /escrow_roles(.:format) escrow_roles#index
POST /escrow_roles(.:format) escrow_roles#create
new_escrow_role GET /escrow_roles/new(.:format) escrow_roles#new
edit_escrow_role GET /escrow_roles/:id/edit(.:format) escrow_roles#edit
escrow_role GET /escrow_roles/:id(.:format) escrow_roles#show
PUT /escrow_roles/:id(.:format) escrow_roles#update
DELETE /escrow_roles/:id(.:format) escrow_roles#destroy
escrows GET /escrows(.:format) escrows#index
POST /escrows(.:format) escrows#create
new_escrow GET /escrows/new(.:format) escrows#new
edit_escrow GET /escrows/:id/edit(.:format) escrows#edit
escrow GET /escrows/:id(.:format) escrows#show
PUT /escrows/:id(.:format) escrows#update
DELETE /escrows/:id(.:format) escrows#destroy
tasks GET /tasks(.:format) tasks#index
POST /tasks(.:format) tasks#create
new_task GET /tasks/new(.:format) tasks#new
edit_task GET /tasks/:id/edit(.:format) tasks#edit
task GET /tasks/:id(.:format) tasks#show
PUT /tasks/:id(.:format) tasks#update
DELETE /tasks/:id(.:format) tasks#destroy
root / home#index
specification /specification(.:format) home#specification
sales /sales(.:format) home#sales
new_user_session GET /users/sign_in(.:format) devise/sessions#new
user_session POST /users/sign_in(.:format) devise/sessions#create
destroy_user_session DELETE /users/sign_out(.:format) devise/sessions#destroy
user_password POST /users/password(.:format) devise/passwords#create
new_user_password GET /users/password/new(.:format) devise/passwords#new
edit_user_password GET /users/password/edit(.:format) devise/passwords#edit
PUT /users/password(.:format) devise/passwords#update
cancel_user_registration GET /users/cancel(.:format) devise/registrations#cancel
user_registration POST /users(.:format) devise/registrations#create
new_user_registration GET /users/sign_up(.:format) devise/registrations#new
edit_user_registration GET /users/edit(.:format) devise/registrations#edit
PUT /users(.:format) devise/registrations#update
DELETE /users(.:format) devise/registrations#destroy
【问题讨论】:
对此有任何答案吗?我在生产时遇到了完全相同的问题。似乎我的设计路线在生产中没有被遵循,但在开发中工作正常 【参考方案1】:答案——在 productiono.rb 中打开 config.log_level = :debug,然后从那里开始工作。事实上,我必须在我的一些布局部分中为以“home”开头的控制器名称添加一个前导正斜杠。
【讨论】:
以上是关于在生产服务器上设计 404 错误,没有路由匹配 :controller=>"devise/home"的主要内容,如果未能解决你的问题,请参考以下文章
如何处理 Ember.js 中的“没有匹配的路由”并显示 404 页面?
laravel5.2 移植到新服务器上除了“/”路由 ,其它路由对应的页面显示报404错误(Object not found!)———新装的LAMP没有加载Rewrite模块