Warden身份验证召回401 Unauthorized

时间:2012-07-13 09:04:44

标签: ruby-on-rails authentication devise

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

在安装后使用rails生成devise:install

使用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)

我如何修复已完成401未经授权?

1 个答案:

答案 0 :(得分:1)

attr_accessor :password 

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