我的 Rails 3.0.9 应用程序遇到了挑战,直到几天前我提交了一些静态内容时,它一直“运行良好”。它在 heroku 上,我使用 Socery Gem 进行身份验证
当我尝试访问它时,我从 Heroku 收到应用程序崩溃错误,查看我的日志我看到了这个
Starting process with command `thin -p 38037 -e production
-R /home/heroku_rack/heroku.ru start`
2012-04-19T16:17:26+00:00 app[web.1]:
/app/.bundle/gems/ruby/1.9.1/gems/activesupport-
3.0.9/lib/active_support/dependencies.rb:304:in `rescue in depend_on':
No such file to load -- bcrypt (LoadError)
在做了一些研究后,补充说
gem 'bcrypt-ruby'
到我的 Gem 文件,现在我的应用程序在 Heroku 上启动,但在日志中使用此用户身份验证失败
←[32m2012-04-23T09:15:48+00:00 app[web.1]:←[0m
←[32m2012-04-23T09:15:48+00:00 app[web.1]:←[0m
←[32m2012-04-23T09:15:48+00:00 app[web.1]:←[0m Started POST "/sessions" for 94.2
00.71.131 at 2012-04-23 02:15:48 -0700
←[32m2012-04-23T09:15:48+00:00 app[web.1]:←[0m
←[32m2012-04-23T09:15:48+00:00 app[web.1]:←[0m NoMethodError (undefined method `
unlock_token' for #<User:0x000000052f7740>):
←[32m2012-04-23T09:15:48+00:00 app[web.1]:←[0m app/controllers/sessions_contro
ller.rb:24:in `create'
最佳答案
我今天遇到了这个问题。您可能缺少用户表中的“unlock_token”字段。您可能应该添加如下迁移:
class AddUnlockTokenToUsers < ActiveRecord::Migration
def change
add_column :users, :unlock_token, :string, :default => nil
end
end
该功能似乎已在此处实现:https://github.com/NoamB/sorcery/pull/249
关于ruby-on-rails-3 - 巫术的身份验证错误 - 没有这样的方法创建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10278037/