Sha256: 95b85f56bf6c331d1ac1f3f9f7cb5bd2d02180f448a541106115f09989956267
Contents?: true
Size: 1.31 KB
Versions: 18
Compression:
Stored size: 1.31 KB
Contents
require 'active_record/autosave_association' module WhyValidationsSuckIn96 module ActiveRecord module AssociationValidation def self.included(klass_or_mod) klass_or_mod.module_eval do extend ClassMethods end end module ClassMethods def self.extended(klass_or_mod) (class << klass_or_mod; self; end).instance_eval do # FIXME - alias method chain my ass alias_method_chain :add_autosave_association_callbacks, :validation_hooks end end def add_autosave_association_callbacks_with_validation_hooks(reflection) add_autosave_association_callbacks_without_validation_hooks(reflection) setup_validations_for_association_reflection(reflection) end private def setup_validations_for_association_reflection(reflection) return false unless reflection.options[:validate] || reflection.options[:autosave] setup_validations { validates_associated reflection.name.to_sym, :on => :save } end end # ClassMethods end # AssociationValidation end # ActiveRecord end # WhyValidationsSuckIn96 ActiveRecord::Base.instance_eval { include WhyValidationsSuckIn96::ActiveRecord::AssociationValidation }
Version data entries
18 entries across 18 versions & 1 rubygems