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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:19:25+00:00 2026-05-22T17:19:25+00:00

I have an authentication method within my User model. I want to be able

  • 0

I have an authentication method within my User model.

I want to be able to call this method like that

User.authenticate(:email => email@exmaple.com, :password => "123")

and

User.authenticate(:remember_token => "asdasds41")

what’s the right way to do that?

I gave a glimpse in rails source (validates function) and I noticed that the function get *attributes, but I didn’t figure out what the * stands for and how to read the inner variables

Tnx for helping

  • 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-22T17:19:26+00:00Added an answer on May 22, 2026 at 5:19 pm

    The method you are speaking of is actually taking a hash of values. The keys within the hash (e.g. :remember_token, :email, and :password) act as named parameters and it does not matter where within the order they appear in the calling statement.

    Also, the hash would normally need to be surrounded by braces (e.g. {…}), but in Ruby the last argument in a method does not require these braces.

    The *attributes that you speak of is a way to pass a dynamic number of arguments to a method as through an array. The *attributes notation instructs Ruby to expand the attributes into a list of arguments.

    The authenticate method you speak of would look something like this:

    class User
    
      def self.authenticate(params)
        puts params[:email]
        puts params[:password]
        puts params[:remember_token]
      end
    
    end
    

    where you would obviously do something other than print out the parameters that you are receiving.

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

Sidebar

Related Questions

I have authentication logic that uses cookies. The model attributes are initialized from cookies,
So I have this black box authentication method, handed down to me from the
Strange thing – I have Authentication module in lib/ like this: module Authentication protected
I have a destroy method within a notecards controller that I am calling from
I'd like to setup Tomcat on Windows and have authentication in my web application
I would like to have the authentication and registration parts of my website encrypted
It looks like JavaScript does not have access to authentication cookies ('ASP.NET_SessionId', '.ASPXFORMSAUTH') in
Within Authlogic, is there a way that I can add conditions to the authentication
I am working on a Rails application that has user authentication which provides an
We have a scenario in which we like to detect when the user has

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.