class ActiveRecord::Base
def self.validates_path(*args)
def self.validates_path(*args) configuration = args.extract_options! 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