app/helpers/sessions_helper.rb
# Returns the current logged in user (if it is any)
Returns the current logged in user (if it is any)
Returns the current logged in user ( if it is any )
def current_user
    if (user_id = session[:user_id])
      @current_user ||= User.find_by(id: user_id)
    elsif (user_id = cookies.encrypted[:user_id])
      user = User.find_by(id: user_id)
      if (user && user.authenticated?(:remember, cookies[:remember_token]))
        log_in  user
        @current_user = user
      end
    end
  end
def current_user if ( user_id = session [ :user_id ] ) @current_user ||= User . find_by ( id : user_id ) elsif ( user_id = cookies . encrypted [ :user_id ] ) user = User . find_by ( id : user_id ) if ( user && user . authenticated? ( :remember , cookies [ :remember_token ] ) ) log_in user @current_user = user end end end
Returns the current logged in user (if it is any)
Returns the current logged in user ( if it is any )