I think that calling #update_attribute on a new record object
should raise an exception, and not have the behavior it has
now.
Right now it does this:
>> p = Post.new
=> #<Post id: nil, title: nil, blog_id: nil, created_at: nil, updated_at: nil, author: nil>
>> p.update_attribute(:title, "My Title")
=> true
>> p
=> #<Post id: 16, title: "My Title", blog_id: nil, created_at: "2011-03-27 13:00:34", updated_at: "2011-03-27 13:00:34", author: nil>
>> p.valid?
=> false
>> p.errors
=> #<ActiveRecord::Errors:0x7f26b3a307b0 @base=#<Post id: 17, title: "My Title", blog_id: nil, created_at: "2011-03-27 13:07:35", updated_at: "2011-03-27 13:07:35", author: nil>, @errors={"blog_id"=>[#<ActiveRecord::Error:0x7f26b3a2e398 @options={}, @type=:blank, @base=#<Post id: 17, title: "p", blog_id: nil, created_at: "2011-03-27 13:07:35", updated_at: "2011-03-27 13:07:35", author: nil>, @message=:blank, @attribute=:blog_id>]}>
Not sure if I would expect it to persist the object, or even
worse, persist an invalid object.
I attach a patch to solve this.