Synopsis . I am trying to change the value of an attribute in a custom ActiveModel::EachValidatorvalidator. Given the following prototype:
def validate_each(record, attribute, value)
trying to install value = thing, seems to be doing nothing - am I missing something? There must be a smart way to do this ...
More details . I accept the URL as part of the site. I don’t want to just use the URL and directly verify that it is returning a message 200 OK, because it will ignore entries that did not start with http, or left leading www, etc. I have some custom logic to handle these errors and follow call forwarding. Thus, I would like the validation to succeed if the user enters example.org/article, and not http://www.example.org/article. The logic works correctly inside the check, but the problem is that if someone enters in the first, the stored value in the database is in the "wrong" form, and not in a well-updated one. Can I change the record during the test to a more canonical form?
source
share