4

我尝试使用全新的 Rails 应用程序设置设计,我已经使用 gemfile 和捆绑安装正确安装了设计

在使用 rails 安装的设计之后生成设计:安装

使用 rails generate devise user 创建了一个新模型

rake db:migrate 创建用户表

添加 devise_for :users do get 'users/sign_out', :to => 'devise/sessions#destroy' end用于使用我的浏览器注销

运行 Rails 服务器

去 localhost:3000/users/sign_up 创建一个新用户

转到 localhost:3000/users/sign_out 将他注销

转到 localhost:3000/users/sign_in 并尝试再次登录他并失败并显示以下内容并将我发送回登录屏幕而不登录

Started POST "/users/sign_in" for 127.0.0.1 at 2012-07-13 16:55:28 +0800
  Processing by Devise::SessionsController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"cbFEP0FJ/e2XYHfub3ZeI7nEX0nCheXzCDs2ner3Zw8=", "newuser"=>{"email"=>"henghong.lee@gmail.com", "password"=>"[FILTERED]", "remember_me"=>"0"}, "commit"=>"Sign in"}
Completed 401 Unauthorized in 1ms
  Processing by Devise::SessionsController#new as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"cbFEP0FJ/e2XYHfub3ZeI7nEX0nCheXzCDs2ner3Zw8=", "newuser"=>{"email"=>"henghong.lee@gmail.com", "password"=>"[FILTERED]", "remember_me"=>"0"}, "commit"=>"Sign in"}
Rendered /Users/Kinnovate/.rvm/gems/ruby-1.9.3-p194/gems/devise-2.1.2/app/views/devise/shared/_links.erb (1.0ms)
Rendered /Users/Kinnovate/.rvm/gems/ruby-1.9.3-p194/gems/devise-2.1.2/app/views/devise/sessions/new.html.erb within layouts/application (4.9ms)
Completed 200 OK in 175ms (Views: 16.5ms | ActiveRecord: 1.3ms)

如何修复 Completed 401 Unauthorized ?

4

1 回答 1

1
attr_accessor :password 

似乎是问题的原因,因为该设计似乎没有为模型创建加密密码

于 2012-07-16T02:34:20.747 回答