Hi i am learning rails from the Odin project and i am creating a simple authentication without using devise . the course doesn’t really give enough info to help beginners finish that project
so, Here is the part that i don’t understand. the login method
class RegistrationController < ApplicationController
def new
@user.new
end
def create
@user = User.new(registration_params)
if @user.save
login @user
redirect_to root_path
else
render :new
class ApplicationController < ActionController::Base
private
def login(user)
Current.user= user
reset_session
session[:user_id] = user.id
end
i don’t understand what Current.user = user does
i can’t find anything for the “Current” object and is user a method in it?
the source code here seems hard for me to understand https://api.rubyonrails.org/classes/ActiveSupport/CurrentAttributes.html
thanks
Student CZ is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.