设计注销路由错误

我在Rails 3.0.3应用程序中使用Devise 1.5.1。 它运作良好,但有一个例外:注销链接给我这个错误:

路由错误

未初始化的常量UsersController

导致这种情况的链接是:

 :delete) %> 

我还没有创建app / controllers / user_controller.rb文件,但是我的理解是在使用Devise时没有必要,对吗?

如果它是相关的,我的routes.rb文件看起来像:

 Su::Application.routes.draw do get "group/create" devise_for :users resources :users resources :payers resources :payments resources :categories resources :groups match "adduser", :to => "groups#adduser" root :to => "pages#home" end 

…和app / models / user.rb看起来像:

 class User < ActiveRecord::Base # Include default devise modules. Others available are: # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable # Setup accessible (or protected) attributes for your model attr_accessible :first_name, :email, :password, :password_confirmation, :remember_me, :group_id end 

我广泛搜索和搜索了SO,但无济于事。 我应该如何解决这样的问题?

在您的路线文件中,您有

devise_for:用户

它适用于Devise的路线,但是

资源:用户

是一个通用的CRUD路由,它使Rails认为在您的应用程序中,您有Users Controller ,并且您正在使用模型中的用户模型。

该错误告诉您没有用户控制器,这是真的,但它正在寻找它,因为路由。
因此,如果要对Users模型执行某些操作,请删除该行或添加用户控制器。

如果有任何不清楚的地方,请将其作为评论发布。