rails/rails — Issue #3599: ActiveModel Dirty empty changes
Author: DanDiac
Created: 2011-11-10 15:10:47+00:00
State: open

Didn't dig up all the stack-trace but this is an example of the bug in action:
user.name #=> "John"
user.name = "Bob"
user.name = "John"
user.save #=> TypeError (can't convert Array to Hash (Array#to_hash gives Array))

Original code from dirty.rb
# Map of changed attrs => [original value, new value].
# person.changes # => {}
# person.name = 'bob'
# person.changes # => { 'name' => ['bill', 'bob'] }
def changes
HashWithIndifferentAccess[changed.map { |attr| [attr, attribute_change(attr)] }]
end

Possible fix:
def changes
changed.empty? ? {} : HashWithIndifferentAccess[changed.map { |attr| [attr, attribute_change(attr)] }]
end

I am using Ruby 1.9.2 with Rails 3.1rc4