這是 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