Ruby on Rails Tuesday, May 17, 2011

On 17 May 2011, at 18:45, "james b." <lists@ruby-forum.com> wrote:

> 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
>
> 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.
>
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
>

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment