p.save not actually saving

i'm not sure if this is the right place for this but it its an activerecord issue so hopefully it is.

anyway when ever i try and save a model it come back as true but when i find the object again it hasn't changed.

For example:

p = Post.find 1 p.title.capitalize! p.save # Returns true but doesn't actually save

the logger outputs the following when i save it

D, [2011-05-17T18:33:55.786908 #5595] DEBUG -- : SQL (0.2ms) BEGIN D, [2011-05-17T18:33:55.787576 #5595] DEBUG -- : SQL (0.1ms) COMMIT => true

Any reason for this?

Thanks, James.

which rails?

try (in console)

p = Post.find 1 p.title.capitalize! p.title p.save

p.errors.inspect

tom

i'm not sure if this is the right place for this but it its an activerecord issue so hopefully it is.

anyway when ever i try and save a model it come back as true but when i find the object again it hasn't changed.

For example:

p = Post.find 1 p.title.capitalize! p.save # Returns true but doesn't actually save

Inplace modification of attributes confuses the change tracking in ar - either don't do it (ie p.title = p.title.capitalize) or call the title_will_change! method after you do

Fred

Thanks very much i had been pondering on this for a while

Final Solution:

p.title = p.title.capitalize instead of p.title.capitalize!

or p.update_attribute(:title, p.title.capitalize) and without p.save

or if you want to capitalize in your model (when saving), you could do that with before filter

before_save do |row|   row.title = row.title.capitalize unless row.title.blank? end

tom