Sha256: 504349953d7ac979caf34aeb5e96eb6e77f118d44c2a35e0f94e6cf6567b24e8
Contents?: true
Size: 974 Bytes
Versions: 3
Compression:
Stored size: 974 Bytes
Contents
# frozen_string_literal: true module ActiveRecord::Associations::Builder class Association def self.build(model, name, scope, options, &block) if model.dangerous_attribute_method?(name) raise ArgumentError, "You tried to define an association named #{name} on the model #{model.name}, but " \ "this will conflict with a method #{name} already defined by Active Record. " \ "Please choose a different association name." end if options[:dependent] == :auto options[:dependent] = if model._destroy_callbacks.empty? :destroy else :delete end end reflection = create_reflection(model, name, scope, options, &block) define_accessors model, reflection define_callbacks model, reflection define_validations model, reflection define_change_tracking_methods model, reflection reflection end end end
Version data entries
3 entries across 3 versions & 1 rubygems