Permalink
Browse files

make save! return true on success[johan@johansorensen.com]. Closes #4173



git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3871 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent c32fa73 commit c42cd3c3834e13bd9eb0a444e0d6073aee548125 @NZKoz NZKoz committed Mar 15, 2006
Showing with 8 additions and 1 deletion.
  1. +2 −0 activerecord/CHANGELOG
  2. +1 −1 activerecord/lib/active_record/base.rb
  3. +5 −0 activerecord/test/base_test.rb
View
@@ -4,6 +4,8 @@
* Allow ordering of calculated results and/or grouped fields in calculations [solo@gatelys.com]
+* Make ActiveRecord::Base#save! return true instead of nil on success. #4173 [johan@johansorensen.com]
+
* Dynamically set allow_concurrency. #4044 [Stefan Kaes]
* Added Base#to_xml that'll turn the current record into a XML representation [DHH]. Example:
@@ -1305,7 +1305,7 @@ def save
# Attempts to save the record, but instead of just returning false if it couldn't happen, it raises a
# RecordNotSaved exception
def save!
- raise RecordNotSaved unless save
+ save || raise(RecordNotSaved)
end
# Deletes the record in the database and freezes this instance to reflect that no changes should
@@ -136,6 +136,11 @@ def test_create
topic_reloaded = Topic.find(topic.id)
assert_equal("New Topic", topic_reloaded.title)
end
+
+ def test_save!
+ topic = Topic.new(:title => "New Topic")
+ assert topic.save!
+ end
def test_hashes_not_mangled
new_topic = { :title => "New Topic" }

0 comments on commit c42cd3c

Please sign in to comment.