Module ActiveModel::Validations::ClassMethods
In: lib/validate_url.rb

Methods

Public Instance methods

Validates whether the value of the specified attribute is valid url.

  class Unicorn
    include ActiveModel::Validations
    attr_accessor :homepage, :ftpsite
    validates_url :homepage, allow_blank: true
    validates_url :ftpsite, schemes: ['ftp']
  end

Configuration options:

  • :message - A custom error message (default is: "is not a valid URL").
  • :allow_nil - If set to true, skips this validation if the attribute is nil (default is false).
  • :allow_blank - If set to true, skips this validation if the attribute is blank (default is false).
  • :schemes - Array of URI schemes to validate against. (default is +[‘http’, ‘https’]+)

[Validate]