app/controllers/sessions_controller.rb
def check_initial_setup
    return unless User.count == 1

    user = User.admins.last

    return unless user && user.require_password?

    token = user.generate_reset_token
    user.save

    redirect_to edit_user_password_path(reset_password_token: token),
      notice: "Please create a password for your new account."
  end
# Handle an "initial setup" state, where there's only one user, it's an admin,
# and they require a password change.
Handle an "initial setup" state, where there's only one user, it's an admin,
and they require a password change.
Handle an " initial setup " state where there ' s only one user it ' s an admin and they require a password change .
def check_initial_setup
    return unless User.count == 1
    user = User.admins.last
    return unless user && user.require_password?
    token = user.generate_reset_token
    user.save
    redirect_to edit_user_password_path(reset_password_token: token),
      notice: "Please create a password for your new account."
  end
def check_initial_setup return unless User . count == 1 user = User . admins . last return unless user && user . require_password? token = user . generate_reset_token user . save redirect_to edit_user_password_path ( reset_password_token : token ) , notice : "Please create a password for your new account." end
Handle an "initial setup" state, where there's only one user, it's an admin,
and they require a password change.
Handle an " initial setup " state where there ' s only one user it ' s an admin and they require a password change .