Module: ActiveUrl::Validations

Defined in:
lib/active_url/validations.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
# File 'lib/active_url/validations.rb', line 45

def self.included(base)
  base.class_eval do
    extend ClassMethods
    include ActiveRecord::Validations
    alias_method_chain :save!, :active_url_exception
    class << self
      alias_method_chain :find, :validation
      alias_method_chain :add_attribute, :validation
    end
  end
end

Instance Method Details

#save_with_active_url_exception!Object



39
40
41
42
43
# File 'lib/active_url/validations.rb', line 39

def save_with_active_url_exception!
  save_without_active_url_exception!
rescue ActiveRecord::RecordInvalid => e
  raise ActiveUrl::RecordInvalid.new(e.record)
end