当我尝试访问“登录”路由 (GET /users/sign_in) 时出现以下错误...
No route matches {:action=>"home", :controller=>"devise/pages"}
这是来自服务器日志的完整错误...
Started GET "/users/sign_in" for 127.0.0.1 at 2012-06-05 00:51:54 -0700
Processing by Devise::SessionsController#new as HTML
Rendered devise/shared/_links.erb (2.9ms)
Rendered devise/sessions/new.html.erb within layouts/application (33.5ms)
Rendered pages/_header.html.erb (75.9ms)
Completed 500 Internal Server Error in 349ms
ActionView::Template::Error (No route matches {:action=>"home", :controller=>"devise/pages"}):
这是我的应用程序/布局的主体......
<!-- BEGIN body -->
<body class="top">
<!-- BEGIN .container -->
<div class="container">
<%= render 'pages/header' %>
<%= render 'pages/menu' %>
<p class="notice"><%= notice %></p>
<p class="alert"><%= alert %></p>
<%= yield %>
<!-- END .container -->
</div>
<%= render 'pages/footer' %>
</body>
我拥有的唯一控制器是“页面”控制器。另外,这是我的 route.rb 文件...
MyApp::Application.routes.draw do
devise_for :users
match '/contact', :to => 'pages#contact'
match '/news', :to => 'pages#news'
match '/home', :to => 'pages#home'
match '/features', :to => 'pages#features'
root :to => 'pages#home'
end
我不知道它是否与它有关,但我也使用rails generate devise:views
命令生成了视图。
当我执行 GET /users/sign_in 时,为什么它试图访问不存在的“设计/页面”控制器和“主页”操作?当我这样做时,这不是我的路线所显示的rake routes
......
new_user_session GET /users/sign_in(.:format) {:action=>"new", :controller=>"devise/sessions"}
user_session POST /users/sign_in(.:format) {:action=>"create", :controller=>"devise/sessions"}
destroy_user_session DELETE /users/sign_out(.:format) {:action=>"destroy", :controller=>"devise/sessions"}
user_password POST /users/password(.:format) {:action=>"create", :controller=>"devise/passwords"}
new_user_password GET /users/password/new(.:format) {:action=>"new", :controller=>"devise/passwords"}
edit_user_password GET /users/password/edit(.:format) {:action=>"edit", :controller=>"devise/passwords"}
PUT /users/password(.:format) {:action=>"update", :controller=>"devise/passwords"}
cancel_user_registration GET /users/cancel(.:format) {:action=>"cancel", :controller=>"devise/registrations"}
user_registration POST /users(.:format) {:action=>"create", :controller=>"devise/registrations"}
new_user_registration GET /users/sign_up(.:format) {:action=>"new", :controller=>"devise/registrations"}
edit_user_registration GET /users/edit(.:format) {:action=>"edit", :controller=>"devise/registrations"}
PUT /users(.:format) {:action=>"update", :controller=>"devise/registrations"}
DELETE /users(.:format) {:action=>"destroy", :controller=>"devise/registrations"}
root / {:controller=>"pages", :action=>"home"}
contact /contact(.:format) {:controller=>"pages", :action=>"contact"}
news /news(.:format) {:controller=>"pages", :action=>"news"}
home /home(.:format) {:controller=>"pages", :action=>"home"}
features /features(.:format) {:controller=>"pages", :action=>"features"}
非常感谢您的智慧!
编辑按要求添加“页面/菜单”部分......
<!-- BEGIN .menu-primary -->
<div class="menu-primary">
<table>
<tr>
<td class="menu">
<ul>
<li>
<a href="/news">News</a>
</li>
<li>
<a href="/features"><span>Shop Products</span></a>
<ul>
<li><a href="/features">Features</a></li>
</ul>
</li>
<li><a href="#"><span>Shop Parts</span></a><ul><li><a href="#">Controls (Coming Soon)</a></li><li><a href="#">Monitors (Coming Soon)</a></li><li><a href="#">Artwork (Coming Soon)</a></li><li><a href="#">Accessories (Coming Soon)</a></li></ul></li>
<li><a href="/contact">Contact Us</a></li>
</ul>
</td>
</tr>
</table>
<!-- END .menu-primary -->
</div>
更新在我的标题模板中,我有......
<%= link_to image_tag("mylogo.png", :alt=>"", :width=>"300", :height=>"100"), {:action => 'home', :controller => 'pages'} %>
删除它可以让我的登录页面成功加载。为什么?!