Module: ActiveModel::Validations::ClassMethods
- Defined in:
- lib/validate_url.rb
Instance Method Summary collapse
-
#validates_url(*attr_names) ⇒ Object
Validates whether the value of the specified attribute is valid url.
Instance Method Details
#validates_url(*attr_names) ⇒ Object
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 isfalse). - :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'])
48 49 50 |
# File 'lib/validate_url.rb', line 48 def validates_url(*attr_names) validates_with UrlValidator, _merge_attributes(attr_names) end |