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

  • Home
  • SEARCH
  • 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 5955547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:07:47+00:00 2026-05-22T18:07:47+00:00

def current_user=(user) @current_user = user end def user_from_remember_token User.authenticate_with_salt(*remember_token) end def remember_token cookies.signed[:remember_token] ||

  • 0
def current_user=(user)
    @current_user = user
end

def user_from_remember_token
    User.authenticate_with_salt(*remember_token)
end

def remember_token
    cookies.signed[:remember_token] || [nil, nil]
end

1) I’m mostly confused with def current_user=(user). What is the = for. I see that it’s taking the user object as a parameter, but what is the point of the = sign.

2) Not sure why there is a * infront of remember_token. Can anyone explain this?

Thanks

  • 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-22T18:07:47+00:00Added an answer on May 22, 2026 at 6:07 pm

    The = at the end of the method name is a syntactic sugar used for methods that assign a value. Since parentheses are optional in Ruby, you can write foo.current_user = (bar) or foo.current_user = bar. Note that the latter looks more natural. Also note that you can use attr_writer :current_user.

    You can also use ? and ! in method names in Ruby. By convention, the former indicates a boolean value to be returned, the latter indicates “dangerous” methods (e.g. that modify the object instead of returning a copy).

    The * wraps whatever what passed to the method into an array. It works also when calling a method, then it unwraps an array.

    The || is simply logical or; if the first operand evaluates to nil or false, the other will be returned. Often you may find foo ||= "bar", which means that foo will get the value of “bar”, unless it has a value (foo = foo || "bar").

    Ruby is a great language with lots of these kind of quirks. Rubyist is a page worth visiting.

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

Sidebar

Related Questions

I have a tweets_controller #called when user submits twitter form def message unless current_user
I think I'm using the Users API incorrectly: class BaseHandler(webapp.RequestHandler): user = users.get_current_user() def
I need to know the ID of the current user in a model: def
def update @album = Album.find(params[:id]) if @album.update_attributes(params[:album]) redirect_to(:action=>'list') else render(:action=>'edit') end end A Rails
def test_method [a, b, c].map {|i| yield(i) } end If I call test_method like
def any? if block_given? method_missing(:any?) { |*block_args| yield(*block_args) } else !empty? end end In
In Restful Authentication , I found that current_user is quite intricate that, when @current_user
I have Teacher, Student, and Parent models that all belong to User. This is
I've got a model like this def upload_location(instance, filename): return 'validate/%s/builds/%s' % (get_current_user(), filename)
I have the following before_filter : def find_current_membership respond_to do |wants| wants.html { @current_membership

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.