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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:08:40+00:00 2026-06-08T04:08:40+00:00

I’m trying to make a sample login with has_secure_password. The gem file is added,

  • 0

I’m trying to make a sample login with has_secure_password. The gem file is added, but this error persists:

undefined local variable or method `password_digest' for #<User:0x23129a0>
app/controllers/sessions_controller.rb:8:in `create'

In this file

sessions_controller.rb

line 8 looks like this:

if user and user.authenticate(params[:password])

class SessionsController < ApplicationController
  def new

  end

  def create
    user = User.find_by_name(params[:name])
    if user and user.authenticate(params[:password])
      session[:user_id] = user.id
      redirect_to admin_url , notice: "Login efetuado com sucesso."
     else
       flash[:notice] = 'Usuario ou senha errados'
       redirect_to login_url
    end
  end

  def destroy
    session[:user_id] = nil
    redirect_to login_url, notice: "Logout Efetuado com sucesso."
  end
end
  • 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-06-08T04:08:41+00:00Added an answer on June 8, 2026 at 4:08 am

    I agree with Béla that this is a duplicate. However, here are step-by-step instructions in case the original answer wasn’t clear enough.

    To add the password_digest to your user model…

    In the console do:

    $ rails generate migration AddPasswordDigestToUsers
    

    This will create a file something like: /db/migrate/20120419234606_add_password_digest_to_users (The fourteen digits at the beginning of your file will be different than mine since it’s basically a time stamp for when you ran the generate command. You can read more on generating stand alone migrations here.)

    Open the migration file you just created and edit so it looks something like this:

    class AddPasswordDigestToUsers < ActiveRecord::Migration
      def change
        add_column :users, :password_digest, :string
      end
    end
    

    Save and close the file. Then, in the console, run:

    $ bundle exec rake db:migrate
    $ bundle exec rake db:test:prepare
    

    At this point, your user model should have the password_digest attribute and (hopefully) you won’t get the error any more.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text

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.