# When i save, rails doesnt update the model instance with the

**URL:** <https://www.ruby-forum.com/t/when-i-save-rails-doesnt-update-the-model-instance-with-the/72989>\
**Category:** Rails\
**Created:** [February 24, 2006, 9:30pm UTC](https://www.ruby-forum.com/t/when-i-save-rails-doesnt-update-the-model-instance-with-the/72989 "2006-02-24T21:30:18Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Noel\_RSMorais](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/779978/32.png) [@Noel\_RSMorais](https://www.ruby-forum.com/u/Noel_RSMorais)\
**Post date:** [February 24, 2006, 9:30pm UTC](https://www.ruby-forum.com/t/when-i-save-rails-doesnt-update-the-model-instance-with-the/72989/1 "2006-02-24T21:30:18Z")

</div>

Hi everybody,

Im using sqlserver (sqlserver adapter).

I think that is some bug.

any idea?

---

<div class="post-metadata">

**Author:** ![Noel\_RSMorais](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/779978/32.png) [@Noel\_RSMorais](https://www.ruby-forum.com/u/Noel_RSMorais)\
**Post date:** [February 24, 2006, 9:45pm UTC](https://www.ruby-forum.com/t/when-i-save-rails-doesnt-update-the-model-instance-with-the/72989/2 "2006-02-24T21:45:28Z")

</div>

Are your saves working?

unless object.save  
raise :Yikes  
end

Perhaps your model isn’t validating?

–  
– Tom M.

---

<div class="post-metadata">

**Author:** ![Noel\_RSMorais](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/779978/32.png) [@Noel\_RSMorais](https://www.ruby-forum.com/u/Noel_RSMorais)\
**Post date:** [March 16, 2006, 12:10am UTC](https://www.ruby-forum.com/t/when-i-save-rails-doesnt-update-the-model-instance-with-the/72989/3 "2006-03-16T00:10:08Z")

</div>

yes, my saves are working fine…

---

<div class="post-metadata">

**Author:** ![Noel\_RSMorais](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/779978/32.png) [@Noel\_RSMorais](https://www.ruby-forum.com/u/Noel_RSMorais)\
**Post date:** [March 16, 2006, 3:05am UTC](https://www.ruby-forum.com/t/when-i-save-rails-doesnt-update-the-model-instance-with-the/72989/4 "2006-03-16T03:05:53Z")

</div>

2006/2/24, Noel R. Morais [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> Im using sqlserver (sqlserver adapter).
> 
> I think that is some bug.
> 
> any idea?

Are you saying that you change the model’s ID and that the save does  
not update the ID of the record ?

I’m not sure that changing the ID is supported.

Check the log to see what gets saved.

Hope that helps !

---

<div class="post-metadata">

**Author:** ![Noel\_RSMorais](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/779978/32.png) [@Noel\_RSMorais](https://www.ruby-forum.com/u/Noel_RSMorais)\
**Post date:** [March 17, 2006, 5:37pm UTC](https://www.ruby-forum.com/t/when-i-save-rails-doesnt-update-the-model-instance-with-the/72989/5 "2006-03-17T17:37:23Z")

</div>

Is your ID column set to auto-increment?

–  
– Tom M.

---

<div class="post-metadata">

**Author:** ![Noel\_RSMorais](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/779978/32.png) [@Noel\_RSMorais](https://www.ruby-forum.com/u/Noel_RSMorais)\
**Post date:** [March 17, 2006, 7:32pm UTC](https://www.ruby-forum.com/t/when-i-save-rails-doesnt-update-the-model-instance-with-the/72989/6 "2006-03-17T19:32:02Z")

</div>

yes …

---

<div class="post-metadata">

**Author:** ![Noel\_RSMorais](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/779978/32.png) [@Noel\_RSMorais](https://www.ruby-forum.com/u/Noel_RSMorais)\
**Post date:** [March 17, 2006, 3:40pm UTC](https://www.ruby-forum.com/t/when-i-save-rails-doesnt-update-the-model-instance-with-the/72989/7 "2006-03-17T15:40:46Z")

</div>

What is happening is that when i do:

m = Model.new  
m.description = ‘Another test’  
puts ‘Work fine’ if m.save  
puts ‘The attribute ID wasn’t updated’ if m.id.nil?  
m = Model.find(:first, :order =\> ‘id desc’ )  
puts m.description

The output is:  
$: Work fine  
$: The attribute ID wasn’t updated  
$: Another test

The record was inserted but the model object wasn’t updated with the  
id of the new record.
