Class: OrbitalFields::UrlLookup::UrlLookupFieldValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- OrbitalFields::UrlLookup::UrlLookupFieldValidator
- Defined in:
- lib/orbital_fields/url_lookup.rb
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/orbital_fields/url_lookup.rb', line 60 def validate_each(record,attribute,value) # Return if value is blank return if value.blank? url_lookup = record.make_url_safe(value) matching_record = record.find_by_url_lookup(url_lookup) if !matching_record.nil? && matching_record != record record.errors[record.lookup_field] << ([:message] || "already exists") return end end |