undefined method `key?' for nil:NilClass with bcrypt-ruby and has_secure_password [closed]

本秂侑毒 提交于 2019-12-25 04:02:44

问题


I'm going through DHH's Agile Web Development with Rails for Rails 3.1. In chapter 14 they create a Users sign-in model/view/controller using the has_secure_password method. My user.rb file looks like this:

    class User < ActiveRecord::Base
      attr_accessible :name, :password_digest, :password, :password_confirmation
      validates :name, presence: true, uniqueness: true
      has_secure_password
    end

now when I go to localhost:3000/users/new I first get some kind of bcrypt-ruby error and then when I reload the page I get a undefined method `key?' for nil:NilClass

I don't know what needs to be done, mike


回答1:


I think I figured out what happened. I installed bcrypt-ruby and ran bundle install but never restarted the server. Everything's working now.



来源:https://stackoverflow.com/questions/10568316/undefined-method-key-for-nilnilclass-with-bcrypt-ruby-and-has-secure-passwor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!