我不小心在我的工作目录上调用了git rm ./ -r
并删除了我的所有代码。没问题我只是简单地调用git pull
来获取最新的代码更新,但是现在我不断从Devise获得路由错误。
我必须致电bundle install
。从此,我不断收到错误:
Routing Error
No route matches {:controller=>"devise/registrations"}
Try running rake routes for more information on available routes.
所以我做的第一件事就是运行rake routes
以查看路线是否存在且确实存在:
members_ban GET /members/ban(.:format) members#ban
members_unban GET /members/unban(.:format) members#unban
members GET /members(.:format) members#index
POST /members(.:format) members#create
new_member GET /members/new(.:format) members#new
edit_member GET /members/:id/edit(.:format) members#edit
member GET /members/:id(.:format) members#show
PUT /members/:id(.:format) members#update
DELETE /members/:id(.:format) members#destroy
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
root / home#index
我将以下代码<%= link_to "New", new_user_registration %>
添加到我的主页视图文件中,看看我是否可以获得更多相关信息:
我收到以下错误:https://gist.github.com/anonymous/5165745
我的路线档案:
Eveco::Application.routes.draw do
get 'members/ban'
get 'members/unban'
resources :members
devise_for :users
root :to => 'home#index'
end
扩展:所以我通过控制台和放大器跟踪了这个问题。错误日志:
Started GET "/users/sign_up" for 127.0.0.1 at 2013-03-14 23:51:38 +0100
Processing by Devise::RegistrationsController#new as HTML
Rendered devise/shared/_links.erb (0.0ms)
Rendered devise/registrations/new.html.erb within layouts/application (5.0ms)
Rendered layouts/_nav.html.erb (0.0ms)
Rendered layouts/_bread.html.erb (2.0ms)
Completed 500 Internal Server Error in 17ms
ActionController::RoutingError (No route matches {:controller=>"devise/registrations"}):
app/views/layouts/_bread.html.erb:11:in `_app_views_layouts__bread_html_erb__280287340_55609968'
app/views/layouts/application.html.erb:27:in `_app_views_layouts_application_html_erb__58597651_53376372'
我的应用程序实现面包屑的方式似乎存在问题。基本上我只想在其中显示控制器和方法,所以我使用它:
<div class="row">
<div class="span12">
<ul class="breadcrumb">
<li><%= link_to "Home", root_path %> <span class="divider">/</span></li>
<% if params[:controller] != 'devise' && params[:controller] != 'users' %>
<% if params[:controller] != 'home' %>
<li>
<a href="#">
<%=
link_to params[:controller].to_s.capitalize,
:controller => params[:controller]
%>
<span class="divider">/</span>
</li>
<li class="active">
<%= params[:action].to_s.capitalize %>
</li>
<% end %>
<% end %>
</ul>
</div>
</div>
如果我从应用程序中删除此部分,则路由就像魅力一样。但是现在它出现了一个新问题。
答案 0 :(得分:1)
根据this issue,它可能是命名空间的问题。
基本上我认为params[:controller]
显示为/devise/registrations
,因为如果你看一下路由的设置方式(请注意最后一列),但是你将它映射到{{1}这就是你必须用作控制器的东西:
users
如果你能以某种方式使用网址助手,也许会更好。也许创建一个哈希将面包屑文本映射到url路径。