Ruby Forum Rails-core > saving dirty objects

Posted by Xavier Noria (fxn)
on 12.05.2008 22:47
(Received via mailing list)
changed_attributes is cleared unconditionally after save (and save!) 
attempts:

    # Clear changed attributes after they are saved.
    def save_with_dirty(*args) #:nodoc:
      save_without_dirty(*args)
    ensure
      changed_attributes.clear
    end

I'd expect that to happen only if save succeeds. Which is the rationale?

-- fxn
Posted by Jeremy Kemper (Guest)
on 12.05.2008 23:37
(Received via mailing list)
On Mon, May 12, 2008 at 1:46 PM, Xavier Noria <fxn@hashref.com> wrote:
>  I'd expect that to happen only if save succeeds. Which is the rationale?
I agree. Do you have a patch?

Best,
jeremy
Posted by Xavier Noria (fxn)
on 13.05.2008 01:05
(Received via mailing list)
On Mon, May 12, 2008 at 11:36 PM, Jeremy Kemper <jeremy@bitsweat.net> 
wrote:
>  >       changed_attributes.clear
>  >     end
>  >
>  >  I'd expect that to happen only if save succeeds. Which is the rationale?
>
>  I agree. Do you have a patch?

Here we go, all AR tests pass (except for an unrelated failure):

   http://rails.lighthouseapp.com/projects/8994/tickets/174-dirty-objects-shouldn-t-clear-changed-attributes-after-a-save-failure#ticket-174-1


-- fxn
Posted by Jeremy Kemper (Guest)
on 13.05.2008 02:07
(Received via mailing list)
On Mon, May 12, 2008 at 4:05 PM, Xavier Noria <fxn@hashref.com> wrote:
>  >  >     def save_with_dirty(*args) #:nodoc:
>
>    http://rails.lighthouseapp.com/projects/8994/tickets/174-dirty-objects-shouldn-t-clear-changed-attributes-after-a-save-failure#ticket-174-1

Thanks Xavier!

jeremy