Flowdock
method

configure_dependency_for_has_one

Importance_0
v1.2.6 - Show latest stable - 0 notes - Class: ActiveRecord::Associations::ClassMethods
configure_dependency_for_has_one(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 1092
        def configure_dependency_for_has_one(reflection)
          case reflection.options[:dependent]
            when :destroy, true
              module_eval "before_destroy '#{reflection.name}.destroy unless #{reflection.name}.nil?'"
            when :delete
              module_eval "before_destroy '#{reflection.class_name}.delete(#{reflection.name}.id) unless #{reflection.name}.nil?'"
            when :nullify
              module_eval "before_destroy '#{reflection.name}.update_attribute(\"#{reflection.primary_key_name}\", nil) unless #{reflection.name}.nil?'"
            when nil, false
              # pass
            else
              raise ArgumentError, "The :dependent option expects either :destroy, :delete or :nullify."
          end
        end
Register or log in to add new notes.