Flowdock
method

configure_dependency_for_belongs_to

Importance_0
v3.0.0 - Show latest stable - 0 notes - Class: ActiveRecord::Associations::ClassMethods
configure_dependency_for_belongs_to(reflection) private

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# File activerecord/lib/active_record/associations.rb, line 1701
        def configure_dependency_for_belongs_to(reflection)
          if reflection.options.include?(:dependent)
            name = reflection.options[:dependent]

            unless [:destroy, :delete].include?(name)
              raise ArgumentError, "The :dependent option expects either :destroy or :delete (#{reflection.options[:dependent].inspect})"
            end

            method_name = "belongs_to_dependent_#{name}_for_#{reflection.name}""belongs_to_dependent_#{name}_for_#{reflection.name}"
            class_eval "def \#{method_name}\nassociation = \#{reflection.name}\nassociation.\#{name} if association\nend\n", __FILE__, __LINE__ + 1
            after_destroy method_name
          end
        end
Register or log in to add new notes.