Method: ActiveRecord::Base.validates_path
- Defined in:
- lib/active_record_extensions/active_record_extensions.rb
.validates_path(*args) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/active_record_extensions/active_record_extensions.rb', line 4 def self.validates_path(*args) configuration = args. validates_each(args, configuration) do |record, attr_name, value| page = Page.find_by_path(value) record.errors.add(attr_name, :page_not_found, default: configuration[:message]) if page.nil? || page.is_a?(FileNotFoundPage) end end |