Flowdock
method

configure_dependency_for_has_one

Importance_0
v2.0.3 - 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 1195
        def configure_dependency_for_has_one(reflection)
          if reflection.options.include?(:dependent)
            case reflection.options[:dependent]
              when :destroy
                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?'"
              else
                raise ArgumentError, "The :dependent option expects either :destroy, :delete or :nullify (#{reflection.options[:dependent].inspect})"
            end
          end
        end
Register or log in to add new notes.