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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:45:48+00:00 2026-06-12T10:45:48+00:00

I watched the RailCasts tutorial #274 on Remember Me and Reset Password. The code

  • 0

I watched the RailCasts tutorial #274 on Remember Me and Reset Password. The code he adds is the following inside user.rb

def send_password_reset
  generate_token(:password_reset_token)
  save!
  UserMailer.password_reset(self).deliver
end

def generate_token(column)
  begin
    self[column] = SecureRandom.urlsafe_base64
  end while User.exists?(column => self[column])
end

Here what I don’t understand is why the save! call inside send_password_reset? Also, I’m not familiar with the syntax in generate_token: self[column]=. Is this the way to set a column inside a database table?

Here’s the create action of the password_resets_controller

  def create
    user = User.find_by_email(params[:email])
    user.send_password_reset if user
    redirect_to root_path, notice: "Email sent with password reset instructions."
  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-12T10:45:50+00:00Added an answer on June 12, 2026 at 10:45 am

    save! saves the object and raises an exception if it fails.


    self[column]=, is a slight meta-programming.

    Usually, when you know the column name, you’d do: self.password_reset_token=. Which is the same as self[:password_reset_token]= or self["password_reset_token"]=.

    So it’s easy to abstract it a bit passing column name as string/symbol.

    Clearer?

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

Sidebar

Related Questions

I watched this tutorial http://www.youtube.com/watch?&v=jTS7JTud1qQ&t=7m57s and I can get the code to output a
I've read this question mentioning Code Bubbles and I've watched their video presentation. The
I've just watched Uncle Bob's presentation on Architecture software : http://www.cleancoders.com/codecast/clean-code-episode-7/show He talks about
I watched video tutorial about pagination in PHP. Author used 4th version of PHP
I've watched the server-side upload code example ... it says next... ... /** *
I have watched railscast http://railscasts.com/episodes/236-omniauth-part-2 And tried to implement the code, everything worked well
I watched the HttpClient progress code but I still have questions I couldn't find
I watched the WWDC tutorial on using storyboards, and can see the benefit if
I watched few videos/webcasts about Oslo but I still fail to see how it
I watched this webcast recently, and I got the sense that a lot of

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.