The history behind the bug here is a little strange.
I have a project that access a DB where all writes have to use stored procedures (don't blame me, I didn't make this decision).
The insert stored procedure takes the parameters and returns the primary key given to the new record. I then set the object's primary key manually and call reload.
This works fine (all the fields look as they should), but calling new_record? on the object still returns true.
Example
c = Company.new
c.name = 'foo'
c.write_new_record
c.new_record? => true
where
def write_new_record
return false unless valid?
result = connection.select_all self.insert_query
self.id = result[0]['idx']
reload
end
insert_query is the method which inserts the parameter values into the sql query.
Like I said, everything works fine except the new_record? flag.
I know this is a bizarre edge case, but I thought I'd file it anyway.