has_one (ActiveRecord::Associations::ClassMethods)

    # File lib/active_record/associations.rb, line 782
          def has_one(association_id, options = {})
            if options[:through]
              reflection = create_has_one_through_reflection(association_id, options)
              association_accessor_methods(reflection, ActiveRecord::Associations::HasOneThroughAssociation)
            else
              reflection = create_has_one_reflection(association_id, options)

              ivar = "@#{reflection.name}"

              method_name = "has_one_after_save_for_#{reflection.name}".to_sym
              define_method(method_name) do
                association = instance_variable_get("#{ivar}") if instance_variable_defined?("#{ivar}")

                if !association.nil? && (new_record? || association.new_record? || association["#{reflection.primary_key_name}"] != id)
                  association["#{reflection.primary_key_name}"] = id
                  association.save(true)
                end
              end
              after_save method_name

              add_single_associated_save_callbacks(reflection.name)
              association_accessor_methods(reflection, HasOneAssociation)
              association_constructor_method(:build,  reflection, HasOneAssociation)
              association_constructor_method(:create, reflection, HasOneAssociation)

              configure_dependency_for_has_one(reflection)
            end
          end