Ruby 爲什麽 securerandom 引入不進來

a1345774000 · August 25, 2021 · Last by a1345774000 replied at August 25, 2021 · 237 hits

這是 client.rb 模板文件

require 'securerandom'
class Client < ApplicationRecord
  validates :client_adress, presence: { message: "メールアドレスを入力" }
  validates :client_adress, format: {with: /\A[^@\s]+@([^@.\s]+\.)+[^@.\s]+\z/, message: "メールアドレスを入力が正しくありません"}
  def Client.new_token
    SecureRandom_urlsafe_base64
  end
end

這是控制器

def temporary
    if request.post?
      @user = params[:email]
      @user.activation_token = Client.new_token
      MailVerifyMailer.welcome_email(@user).deliver_now
    end  
end  

報錯内容顯示 uninitialized constant #Class:0x00007f02d8297480::SecureRandom_urlsafe_base64 報錯行:SecureRandom_urlsafe_base64

SecureRandom.urlsafe_base64
You need to Sign in before reply, if you don't have an account, please Sign up first.