Posted about 1 month ago. Visible to the public. Linked content. Auto-destruct in 3 days

Updated: Order of the state_machine callback chain

Removed outdated callback cancelling.

Changes

  • 1. before transition
  • 2. before validation
  • 3. after validation
  • 4. before save
  • 5. after save
  • 6. after transition
  • Aborting the callback chain
  • +---------------------------
  • -- You **can** interrupt the callback chain by returning `false` in `before_transition`.
  • -- You **can not** prevent the record from being saved by manually adding an validation error during `before_transition`.
  • -- You **can** rollback the database update by raising an error in `after_transition`. The error will bubble up to the caller, no changes will be saved.
  • -- You **can not** interrupt the callback chain by returning `false` in `after_transition`.
  • -
  • -Similar cards
  • -Also see [Cancel the ActiveRecord callback chain](https://makandracards.com/makandra/20301-cancel-the-activerecord-callback-chain).
  • +See [Cancel the ActiveRecord callback chain](https://makandracards.com/makandra/20301-cancel-the-activerecord-callback-chain).
Growing Rails Applications in Practice
Check out our new e-book:
Learn to structure large Ruby on Rails codebases with the tools you already know and love.

Owner of this card:

Avatar
Jakob Scholz
Last edit:
about 1 month ago
by Jakob Scholz
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Jakob Scholz to makandra dev
This website uses short-lived cookies to improve usability.
Accept or learn more