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

前端 未结 3 602
说谎
说谎 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.

    0 讨论(0)
  • 2020-12-18 17:44

    Just want to let you know that i had this problem as well. The issue was quickly solved but the server showed the error every request afterwards. Code changes have not been reflected until i restarted the server.

    touch tmp/restart.txt was not sufficient so i had to restart the server /etc/init.d/apache2 restart to remove the error message.

    $ apache2 -v
    Server version: Apache/2.2.16 (Debian)
    Server built:   Apr  1 2012 07:14:38
    
    $ ruby -v
    ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
    
    $ gem list passenger
    *** LOCAL GEMS ***
    passenger (3.0.13)
    
    $ bundle exec rails -v
    Rails 3.0.7
    
    0 讨论(0)
  • 2020-12-18 18:06

    Apparently there was nothing wrong with the code. It was probably related to my browsers cache or something of that nature, as it started working the next day. Sorry for the inconvenience.

    0 讨论(0)
提交回复
热议问题