mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Include user defined attributes in inspect
The fact that this only includes column names is an oversight.
This commit is contained in:
parent
b347156b15
commit
8ab9daf280
2 changed files with 7 additions and 1 deletions
|
@ -500,7 +500,7 @@ module ActiveRecord
|
|||
# We check defined?(@attributes) not to issue warnings if the object is
|
||||
# allocated but not initialized.
|
||||
inspection = if defined?(@attributes) && @attributes
|
||||
self.class.column_names.collect do |name|
|
||||
self.class.attribute_names.collect do |name|
|
||||
if has_attribute?(name)
|
||||
"#{name}: #{attribute_for_inspect(name)}"
|
||||
end
|
||||
|
|
|
@ -249,5 +249,11 @@ module ActiveRecord
|
|||
model.foo = "lol"
|
||||
refute model.changed?
|
||||
end
|
||||
|
||||
test "attributes not backed by database columns appear in inspect" do
|
||||
inspection = OverloadedType.new.inspect
|
||||
|
||||
assert inspection.include?("non_existent_decimal")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue