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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:03:18+00:00 2026-06-13T05:03:18+00:00

In the Michael Hartl tutorial, chapter 8, we set up the sign in page

  • 0

In the Michael Hartl tutorial, chapter 8, we set up the sign in page and create a new column in the database to hold a base 64 string. In the tutorial it’s called a remember_token. In the user.rb:

  private

    def create_remember_token
        self.remember_token = SecureRandom.urlsafe_base64
    end

self has a property called remember_token? Is this already built in or did it get created elsewhere? Maybe I’m just not understanding this very well.

He writes:

Because of the way Active Record synthesizes attributes based on
database columns, without self the assignment would create a local
variable called remember_token, which isn’t what we want at all. Using
self ensures that assignment sets the user’s remember_token so that it
will be written to the database along with the other attributes when
the user is saved.

I’m confused, how did the user get a remember token? How does it know to write this to the database in that particular column?

In the user.rb you have the following code:

attr_accessible :name, :email, :password, :password_confirmation

There’s nothing about remember_token there. How does it know to include this at User.save?

  • 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-13T05:03:19+00:00Added an answer on June 13, 2026 at 5:03 am

    In this context, self is a User object, and it has a remember_token attribute because of the database column created by the migration in Section 8.2.1 of the Ruby on Rails Tutorial. (Prepending self is necessary to assign to the attribute; without self, Ruby would just create a local variable called remember_token.)

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

Sidebar

Related Questions

I am working on Michael Hartl's tutorial (chapter 6). When I try to create
On Chapter 7 from Michael Hartl's tutorial there is a User model < code
I'm trying to follow Michael Hartl's Ruby on Rails Tutorial in http://ruby.railstutorial.org/chapters/sign-in-sign-out , but
I am new to RoR3 am following along with the RoR3 Michael Hartl Tutorial.
I'm looking at some RSpec code in Chapter 6 of Michael Hartl's [Rail Tutorial]:
New to Ruby on Rails and having a problem when following Michael Hartl's tutorial.I'm
I am working through Michael Hartl's Ruby on Rails Tutorial Chapter 5 exercises and
I'm learning rails. I on chapter 7 of Michael Hartl's rails tutorial. I am
I am working on Michael Hartl Rails tutorial (currently chapter 7). When I try
I'am working with Michael Hartl Tutorial. In chapter 7 I've found problem that I

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.