1

我的 Rails 版本是 3.2.12。我使用以下命令来创建用户身份验证:

rails generate devise:install
rails generate devise users
rake db:migrate

以下是我的路线

        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

但是即使用户电子邮件和密码保存在数据库中,我仍然无法注册新用户或登录应用程序。以下是我得到的错误:

NameError in Devise::RegistrationsController#create
uninitialized constant Model

我可能错在哪里?

4

2 回答 2

2

试试这个来改变 devise.rb 的这一行

config.sign_out_via = :delete

config.sign_out_via = :get

这个对我有用

于 2013-03-15T07:30:51.497 回答
0

在你的路线上试试这个,

devise_for :users, :controllers => {:registrations => "devise/registrations"} 得到 '/register' => 'devise/registrations#new', :as => :new_user_registration end

于 2013-03-15T06:15:06.027 回答