Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

State transitions do not persist to DB in ActiveRecord models

#18

foo.bar! does not persist to the database due to a failed validation. The documentation for the WriteState::aasm_write_state method indicates that update_attribute is being used to bypass validation, but this is not the case.

After calling write_attribute, save is being called to persist the changes. Since save does validation, this breaks the design of state transitions in AASM.

A proposed fix would be to call save(false) to skip validation, see pastie:

http://www.pastie.org/444480

Reported by Jaryl Sim · April 12th, 2009 @ 05:07 PM

State: new
Milestone: none
Assigned to: Scott Barron Scott Barron

Activity

  1. Travis Tilley
    Travis Tilley

    this is included in the latest AASM

    October 24th, 2009 @ 01:28 AM

  2. Hans Friedrich
  3. Jaryl Sim
    Jaryl Sim

    @Hans I am thinking that the original author did not intend for invalid models to persist. Instead, they opted to fix the misleading comment.

    July 26th, 2010 @ 09:49 PM

  4. Jens
    Jens

    this is unfortunate. It breaks our application in a lot of places. Can this please be made configurable?

    March 8th, 2011 @ 01:20 AM

  5. sara ceejay
    sara ceejay

    Very informative blog! These kind of post are always inspiring and I prefer to read quality content so I happy to find many good point here in the post, writing is simply great, thank you for the post. Camden Chronicle

    August 14th, 2011 @ 03:56 PM

  6. Ralphlauren Boss
    Ralphlauren Boss

    You have provided a great piece of information. I will definitely share it with my other friends. Keep up the good work, I would to stay in contact with your posts.
    info@ralf(Ralphlauren).com

    December 19th, 2011 @ 03:57 PM

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.