Flowdock
method

configure_dependency_for_belongs_to

Importance_0
v2.3.8 - 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 1494
        def configure_dependency_for_belongs_to(reflection)
          if reflection.options.include?(:dependent)
            case reflection.options[:dependent]
              when :destroy
                method_name = "belongs_to_dependent_destroy_for_#{reflection.name}".to_sym
                define_method(method_name) do
                  association = send(reflection.name)
                  association.destroy unless association.nil?
                end
                after_destroy method_name
              when :delete
                method_name = "belongs_to_dependent_delete_for_#{reflection.name}".to_sym
                define_method(method_name) do
                  association = send(reflection.name)
                  association.delete unless association.nil?
                end
                after_destroy method_name
              else
                raise ArgumentError, "The :dependent option expects either :destroy or :delete (#{reflection.options[:dependent].inspect})"
            end
          end
        end
Register or log in to add new notes.