On 12 Nov 2008, at 12:30, Mattias Bud wrote:
> > Something like this > > p = Post.find(1) > > c = p.comments.first > c.destory > > p.save >> StaleObjectError > > This fails because the counter cache of comments in the post model is > now changed. > > Anyway around this? > > OK. So first off suppressing the increment of lock_version would probably meant that your counter cache value would get stomped on (although with partial updates in 2.1 you might get away with it). the easiest way would be to reload p after having done stuff to comments, or alternatively you might be able to do the stuff you need to do to p before you play with the comments. Yet another way might be to do stuff to c.post instead of doing them to p. Fred --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---