aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/base.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-01-15 17:45:16 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-01-15 17:45:16 +0000
commit823554eafef9e8ee8fe2788f6231a3e665c2cbbf (patch)
tree6059c8e2c943a7fb45a56bf80cc5786934b70de1 /activerecord/lib/active_record/base.rb
parent62f0512e54d594c4bb6fcb8d16101fdeb87b89e8 (diff)
downloadrails-823554eafef9e8ee8fe2788f6231a3e665c2cbbf.tar.gz
rails-823554eafef9e8ee8fe2788f6231a3e665c2cbbf.tar.bz2
rails-823554eafef9e8ee8fe2788f6231a3e665c2cbbf.zip
Added support for associating unsaved objects #402 [Tim Bates]
Added replace to associations, so you can do project.manager.replace(new_manager) or project.milestones.replace(new_milestones) #402 [Tim Bates] Added build and create methods to has_one and belongs_to associations, so you can now do project.manager.build(attributes) #402 [Tim Bates] Fixed that Base#== wouldn't work for multiple references to the same unsaved object #402 [Tim Bates] Added that if a before_* callback returns false, all the later callbacks and the associated action are cancelled. If an after_* callback returns false, all the later callbacks are cancelled. Callbacks are generally run in the order they are defined, with the exception of callbacks defined as methods on the model, which are called last. #402 [Tim Bates] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@417 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record/base.rb')
-rwxr-xr-xactiverecord/lib/active_record/base.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 8b022ef6d4..ae743b086a 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -789,7 +789,6 @@ module ActiveRecord #:nodoc:
# * A record does exist: Updates the record with values matching those of the object attributes.
def save
create_or_update
- return true
end
# Deletes the record in the database and freezes this instance to reflect that no changes should
@@ -928,9 +927,9 @@ module ActiveRecord #:nodoc:
self.class.columns_hash[name.to_s]
end
- # Returns true if the +comparison_object+ is of the same type and has the same id.
+ # Returns true if the +comparison_object+ is the same object, or is of the same type and has the same id.
def ==(comparison_object)
- comparison_object.instance_of?(self.class) && comparison_object.id == id
+ comparison_object.equal?(self) or (comparison_object.instance_of?(self.class) and comparison_object.id == id)
end
# Delegates to ==
@@ -956,6 +955,7 @@ module ActiveRecord #:nodoc:
private
def create_or_update
if new_record? then create else update end
+ return true
end
# Updates the associated record with values matching those of the instant attributes.