Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7525137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:27:19+00:00 2026-05-30T03:27:19+00:00

Possible Duplicate: Can't convert String into integer in ruby/ruby-on-rails I’m running through a tutorial

  • 0

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

I’m running through a tutorial on Lynda for learning rails and I’m running into a problem. I’ve built an AccessController to work with an AdminUser model I have. I’m using a string/time salt combo and saving that to the Db, then trying to authenticate using a login form. Here is some code from AccessController

  def attempt_login
authorized_user = AdminUser.authenticate(params[:username], params[:password])
#authorized_user = nil

if authorized_user
    flash[:notice] = "You are logged in now"
    redirect_to(:action => 'menu')
else
    flash[:notice] = "invalid username/password combo"
    redirect_to(:action => 'login')
end

end

And then some from my model where I define the authenticate method:

    def self.authenticate(username="", password="")

    user = AdminUser.find_by_username(username)
    if user && user.password_match?(password)
        return user
    else
        return false
    end
end

    def password_match?(password="")
    hashed_password == AdminUser.hash_with_salt(password, salt)
end

All the hash_with_salt method does is take salt from the DB for that user and makes sure the password entered is salted/encryped with the same salt. Here’s the error I’m continuously getting:

TypeError in AccessController#attempt_login

can't convert String into Integer

Rails.root: /Users/UNAME/Sites/simple_cms
Application Trace | Framework Trace | Full Trace

activesupport (3.1.3) lib/active_support/descendants_tracker.rb:22:in `delete'
activesupport (3.1.3) lib/active_support/descendants_tracker.rb:22:in `block in clear'
activesupport (3.1.3) lib/active_support/descendants_tracker.rb:20:in `each'
activesupport (3.1.3) lib/active_support/descendants_tracker.rb:20:in `clear'
railties (3.1.3) lib/rails/application/bootstrap.rb:56:in `block (2 levels) in <module:Bootstrap>'
activesupport (3.1.3) lib/active_support/callbacks.rb:395:in `_run_cleanup_callbacks'
activesupport (3.1.3) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.1.3) lib/action_dispatch/middleware/reloader.rb:72:in `rescue in call'
actionpack (3.1.3) lib/action_dispatch/middleware/reloader.rb:67:in `call'
rack (1.3.6) lib/rack/sendfile.rb:101:in `call'
actionpack (3.1.3) lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
actionpack (3.1.3) lib/action_dispatch/middleware/show_exceptions.rb:47:in `call'
railties (3.1.3) lib/rails/rack/logger.rb:13:in `call'
rack (1.3.6) lib/rack/methodoverride.rb:24:in `call'
rack (1.3.6) lib/rack/runtime.rb:17:in `call'
activesupport (3.1.3) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.3.6) lib/rack/lock.rb:15:in `call'
actionpack (3.1.3) lib/action_dispatch/middleware/static.rb:53:in `call'
railties (3.1.3) lib/rails/engine.rb:456:in `call'
rack (1.3.6) lib/rack/content_length.rb:14:in `call'
railties (3.1.3) lib/rails/rack/log_tailer.rb:14:in `call'
rack (1.3.6) lib/rack/handler/webrick.rb:59:in `service'
/Users/UNAME/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
/Users/UNAME/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
/Users/UNAME/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'

Any help would be greatly appreciated. I’m certain I’m doing the exact same thing as the tutorial, but maybe there’s an error because of differing Ruby/Rails versions? Searched for hours on this with most of the results discussing the inject() method and that is not helpful. Thanks again!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T03:27:21+00:00Added an answer on May 30, 2026 at 3:27 am

    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
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How can I convert string to double in C++? how can I
Possible Duplicate: how can I convert String to Int ? Hi, I have the
Possible Duplicate: How can I convert a string to boolean in JavaScript? Hi, How
Possible Duplicate: string to float conversion? how can i convert a string to float
Possible Duplicate: Convert a String to Number - Java String s=1,000.0; how can I
Possible Duplicate: How can I convert my java program to an .exe file ?
Possible Duplicate: How can I convert ereg expressions to preg in PHP? I need
Possible Duplicate: How can I convert my java program to an .exe file ?
Possible Duplicate: Convert HTML to PDF in .NET How can i use the acrobat
Possible Duplicate: Compiling a java program into an exe Hi, I'd like to convert

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.