Can't convert String into integer in ruby/ruby-on-rails

前端 未结 3 619
说谎
说谎 2020-12-18 17:30

I want to verify if a user exists, and if so, do a password match.

My controller looks like this:

def attempt_login
    authorized_user = User.authen         


        
3条回答
  •  青春惊慌失措
    2020-12-18 17:43

    I had this same problem and spent hours trying to fix it. It turned out that I had left in a method that the tutorial had told me to delete a few videos beforehand:

     def self.hash(password="")
       Digest::SHA1.hexdigest(password)
     end
    

    In the tutorial, this had been replaced by the methods

     def self.make_salt(username="")
       Digest::SHA1.hexdigest("Use #{username} with #{Time.now} to make salt")
     end
    
     def self.hash_with_salt(password="", salt="")
       Digest::SHA1.hexdigest("Put #{salt} on the #{password}")
     end
    

    Once I commented this method out, the error went away. I still don't understand why that error showed up in the first place. I added a question and more detail here.

提交回复
热议问题