申し訳ありません!
[35] pry(main)> record.errors.add
NameError: undefined local variable or method `record' for main:Object
from (pry):35:in `__pry__'
[36] pry(main)> record.errors.messages
NameError: undefined local variable or method `record' for main:Object
from (pry):36:in `__pry__'
このようになりました。
class NameValidator < ActiveModel::Validator
def validate(record)
uri = URI.parse("https://github.com/#{record.name}")
response = Net::HTTP.get_response(uri)
if response.code == "404"
record.errors.add(:name, message: 'GitHubに存在するユーザー名しか登録できません'
record.errors.messages
end
end
end
=> :validate
このように表示されました。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2022/08/14 03:14
2022/08/14 03:45
2022/08/14 05:16
2022/08/14 05:25
2022/08/14 05:32
2022/08/14 09:57
2022/08/14 10:28
2022/08/14 12:36
2022/08/15 01:50 編集
2022/08/15 13:37
2022/08/16 07:52