我在这里查看了所有Devise路由错误讨论,但找不到解决我问题的解决方案。我的环境如下: - Ruby 1.9.3 - Rails 3.2.6 - 设计2.2.0
我按照此处的所有步骤操作:https://github.com/plataformatec/devise
文件是:
routes.rb中:
Dealzhunt::Application.routes.draw do
devise_for :members
get "browse/all"
get "home/index"
root :to => 'browse#all'
# some other code
member.rb:
class Member < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me
# attr_accessible :title, :body
end
rake routes:
new_member_session GET /members/sign_in(.:format) devise/sessions#new
member_session POST /members/sign_in(.:format) devise/sessions#create
destroy_member_session DELETE /members/sign_out(.:format) devise/sessions#destroy
member_password POST /members/password(.:format) devise/passwords#create
new_member_password GET /members/password/new(.:format) devise/passwords#new
edit_member_password GET /members/password/edit(.:format) devise/passwords#edit
PUT /members/password(.:format) devise/passwords#update
cancel_member_registration GET /members/cancel(.:format) devise/registrations#cancel
member_registration POST /members(.:format) devise/registrations#create
new_member_registration GET /members/sign_up(.:format) devise/registrations#new
edit_member_registration GET /members/edit(.:format) devise/registrations#edit
PUT /members(.:format) devise/registrations#update
DELETE /members(.:format) devise/registrations#destroy
browse_all GET /browse/all(.:format) browse#all
root / browse#all
对于以下网址:
http://localhost:3000/members/sign_in
http://localhost:3000/members/sign_up
我收到以下错误:
No route matches {:controller=>"devise/browse", :action=>"all", :category=>0}
我观察到的一个奇怪的症状是,如果我修改root:to =&gt; 'home #index',消息是一样的。我认为它至少会改为设计/家庭,但它仍然在/浏览
最奇怪的是我开始了一个新的干净轨道项目,设计实际上是有效的。我想知道是不是因为当我运行rails generate devise:install
时发生了一些错误真的遇到了这个问题。有人能帮帮我吗?
答案 0 :(得分:1)
<%= link_to "Home", :controller => "/browse", :action => "all" %>
控制器名称前面的/。以下是有关该问题的更多详细信息:github.com/plataformatec/devise/issues/471
答案 1 :(得分:0)
你在哪里得到这个错误?即,您正在加载哪个页面?
看起来你有一个链接或其他东西路由到控制器“设计/浏览” - 相反,它应该只路由到控制器“浏览”。在rake路由生成的输出中
browse_all GET /browse/all(.:format) browse#all
你会看到你显然拥有一个browse
控制器并使用all
方法。