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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:59:46+00:00 2026-06-18T12:59:46+00:00

I am trying to create an authentication system on RAILS with find_by_user_name_and_password() I have

  • 0

I am trying to create an authentication system on RAILS with find_by_user_name_and_password()

I have the following problem:

undefined method `find_by_user_name_and_password' for #<Class:0x007fae373d5698>
Rails.root: /ror/blog/Blog`

Application Trace | Framework Trace | Full Trace
app/controllers/sessions_controller.rb:7:in `create'

Here is my code from sessions_controller

    class SessionsController < ApplicationController
    skip_before_filter :authorizes
  def new
  end

  def create
        user = User.find_by_user_name_and_password(params[:name], params[:password]) 
        if user
            session[:user_id] = user.id
            redirect_to admin_url
        else
            redirect_to login_url, alert: "Bad datas"
        end
  end

  def destroy
    session[:user_id] = nil
    rederect_to blog_url, notice: "End seans"
  end
end

model defenition:

class User < ActiveRecord::Base
  attr_accessible :name, :password_digest, :password_confirmation
  validates :name, presence: true, uniqueness: true
    #validates_confirmation_of :password  
  has_secure_password
end

Migrate

class CreateUsers < ActiveRecord::Migration
  def change
    create_table :users do |t|
      t.string :name
      t.string :password_digest

      t.timestamps
    end
  end
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-18T12:59:48+00:00Added an answer on June 18, 2026 at 12:59 pm

    Looking at your model that you just posted, I see you don’t have a password field… so no find_by_whatever_and_password.

    You need to use

    user = User.find_by_name(params[:user][:name])
    if user && user.authenticate(params[:user][:password])
      # etc.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a login system in Rails 3 where I can access
I have an MVC 3 app I am trying to create some custom authentication
I am following Michael's ROR tutorial and creating user authentication system. There is an
I am trying to create my own authentication system by making use of Django
I'm trying to write a custom authentication class for xwiki . I have a
I have been trying to write an basic authentication system as part of a
I am trying to create an authentication system in an iOS app that allows
I'm super new to Ruby on Rails. I'm trying to make an authentication system
I am trying to create a custom authentication scheme in ASP.NET MVC using form
I'm trying to create a public gist via javascript. I'm not using any authentication

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.