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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:20:34+00:00 2026-06-05T03:20:34+00:00

In this book: http://ruby.railstutorial.org/chapters/updating-showing-and-deleting-users#code:current_user_p The author does the following: def current_user @current_user ||= User.find_by_remember_token(cookies[:remember_token])

  • 0

In this book:
http://ruby.railstutorial.org/chapters/updating-showing-and-deleting-users#code:current_user_p

The author does the following:

  def current_user
    @current_user ||= User.find_by_remember_token(cookies[:remember_token])
  end

  def current_user?(user)
    user == current_user
  end

my question is when there is a comparison, user == current_user; what is rails comparing? user == @current_user? or user.name == @current_user.name ?

What would hapen if I had the following

  def current_user
    @current_user ||= User.find_by_remember_token(cookies[:remember_token])
    @other_user ||= User.find_by_other_token(cookies[:other_token])
  end

would ser == current_user compare other_user?

  • 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-05T03:20:35+00:00Added an answer on June 5, 2026 at 3:20 am

    The current_user in user == current_user is a call to the current_user method, and in ruby a method returns the last statement that is executed. So in the example, @current_user is being compared to user.

    If you add @other_user to the current_user method, then you are correct in thinking that user == current_user would compare user to @other_user.

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

Sidebar

Related Questions

I am practicing this RoR tutorial project of Michael Hartl: http://ruby.railstutorial.org/ruby-on-rails-tutorial-book I am using
I am learning ruby from this guide http://ruby.railstutorial.org/ruby-on-rails-tutorial-book#sec:deploying , and I am trying to
I'm following this tutorial http://ruby.railstutorial.org/ruby-on-rails-tutorial-book My question is, what is the relation for user
I am trying to set up an environment as per this tutorial http://railstutorial.org/book#sec:1.2.2.3 however
I've build my own basic blog-tool with Rails 3.1 based upon http://ruby.railstutorial.org/ruby-on-rails-tutorial-book and with
I am new to Rails & Ruby and have been following the http://ruby.railstutorial.org/ruby-on-rails-tutorial-book and
I already read this trick in the cookbook: http://book.cakephp.org/2.0/en/models/model-attributes.html#usetable Now I would like to
I'm new to cakephp and following this tutorial. http://book.cakephp.org/2.0/en/tutorials-and-examples/blog-auth-example/auth.html I have created the blog
I used this tutorial: http://book.cakephp.org/2.0/en/tutorials-and-examples/blog-auth-example/auth.html To build my first form/create user app, but it
I tried to implement rss feed following this simple explanation from cake book http://book.cakephp.org/2.0/en/core-libraries/helpers/rss.html

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.