Class: Exstatic::Validators::NonexistantPathValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- Exstatic::Validators::NonexistantPathValidator
- Defined in:
- lib/exstatic/validators/nonexistant_path_validator.rb
Instance Method Summary collapse
Instance Method Details
#validate_each(object, attribute, value) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/exstatic/validators/nonexistant_path_validator.rb', line 4 def validate_each(object, attribute, value) return true if value.blank? path = '/' + value begin route = Rails.application.routes.recognize_path(path, :method => :get) if route && !route[:controller].starts_with?("exstatic/") object.errors[attribute] << ([:message] || "matches an existing path") end rescue ActionController::RoutingError end end |