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 6077861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:46:06+00:00 2026-05-23T10:46:06+00:00

I am completely new to Ruby and trying to learn the language. I am

  • 0

I am completely new to Ruby and trying to learn the language. I am using the book Agile Web Development with Rails and in the chapter about creating using accounts, I keep receiving the error:

Processing by UsersController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"Ykj1a4971bgeEXuftslIgPErK67VTvPlTpcg//Wx8R8=", "user"=>{"name"=>"testaccount", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}, "commit"=>"Create User"}
Completed 500 Internal Server Error in 16ms

NoMethodError (undefined method `salt=' for #<User:0x00000009008b70>):
  app/models/user.rb:41:in `generate_salt'
  app/models/user.rb:29:in `password='
  app/controllers/users_controller.rb:43:in `new'
  app/controllers/users_controller.rb:43:in `create'

Below is the code in my user.rb file:

require 'digest/sha2'

class User < ActiveRecord::Base
  validates :name, :presence => true, :uniqueness => true

  validates :password, :confirmation => true
  attr_accessor :password_confirmation
  attr_reader   :password

  validate  :password_must_be_present

  def User.authenticate(name, password)
    if user = find_by_name(name)
      if user.hashed_password == encrypt_password(password, user.salt)
        user
      end
    end
  end

  def User.encrypt_password(password, salt)
    Digest::SHA2.hexdigest(password + "wibble" + salt)
  end

  # 'password' is a virtual attribute
  def password=(password)
    @password = password

    if password.present?
      generate_salt
      self.hashed_password = self.class.encrypt_password(password, salt)
    end
  end

  private

    def password_must_be_present
      errors.add(:password, "Missing password") unless hashed_password.present?
    end

    def generate_salt
      self.salt = self.object_id.to_s + rand.to_s
    end
end

Any ideas what could be causing my problem. If you need more information let me know which files to list the code from.

  • 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-23T10:46:06+00:00Added an answer on May 23, 2026 at 10:46 am

    The more I learn about Ruby and Rails, the more I realize that I don’t write much of my own code.

    I believe using something like Devise would greatly ease your pain in encrypting your own stuff.

    This is a suggestion that may assist you greatly in this problem and more to come.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

New to rails/ruby (using rails 3 and ruby 1.9.2), and am trying to get
I am new to Ruby on Rails and I'm desperately trying to get a
I'm using Ruby on Rails 3.0.8. I'm trying to follow the tutorial by Ryan
I'm completely new to Ruby and Web Services. I want to tap into SharePoint
Just starting to learn Ruby on Rails. I'm using RoR 3. I have read
I am new to Ruby on Rails. I am trying to develop a website
OK, so I'm really new to Ruby on Rails. I'm using InstantRails, if that
I'm completely new to ruby and I'm trying to format the created_at field pulled
I am completely new to Ruby and need to use Ruby on Rails 2.3.5
I'm trying to build a new rails 3 app from scratch using OmniAuth. Currently

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.