Permalink
Browse files

Fix regression from [1631] that caused an attribute to be set to nil …

…if it was assigned false

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1709 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 56fa64e commit 56c3d72aa75dd286e35a220f53297e043e799ab2 @jamis jamis committed Jul 5, 2005
Showing with 7 additions and 1 deletion.
  1. +1 −1 activerecord/lib/active_record/base.rb
  2. +6 −0 activerecord/test/base_test.rb
@@ -1200,7 +1200,7 @@ def method_missing(method_id, *args, &block)
# Returns the value of attribute identified by <tt>attr_name</tt> after it has been type cast (for example,
# "2004-12-12" in a data column is cast to a date object, like Date.new(2004, 12, 12)).
def read_attribute(attr_name)
- if value = @attributes[attr_name]
+ if !(value = @attributes[attr_name]).nil?
if column = column_for_attribute(attr_name)
if unserializable_attribute?(attr_name, column)
unserialize_attribute(attr_name)
@@ -180,6 +180,12 @@ def test_write_attribute
assert_equal "Still another topic: part 2", topic.title
end
+ def test_read_attribute_when_false
+ topic = topics(:first)
+ topic.approved = false
+ assert_equal 0, topic.approved, "approved should be 0"
+ end
+
def test_preserving_date_objects
# SQL Server doesn't have a separate column type just for dates, so all are returned as time
if ActiveRecord::ConnectionAdapters.const_defined? :SQLServerAdapter

0 comments on commit 56c3d72

Please sign in to comment.