Skip to content

Instantly share code, notes, and snippets.

@muzfuz
Last active October 14, 2016 08:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save muzfuz/7d58516f77293d5f1b67edab55b44efa to your computer and use it in GitHub Desktop.
Save muzfuz/7d58516f77293d5f1b67edab55b44efa to your computer and use it in GitHub Desktop.
Rails Callback Order

##Rails Callback Order of Execution - With and Without state_machines

###Rails Callback Order

  • (-) save
  • (-) valid
  • (1) before_validation
  • (-) validate
  • (2) after_validation
  • (3) before_save
  • (4) before_create
  • (-) create
  • (5) after_create
  • (6) after_save
  • (7) after_commit

###Rails Callbacks with state_machine(s) Bold means they belong to state_machine(s)

  • (-) save
  • (-) begin transaction (if enabled)
  • (1) before_transition
  • (-) valid
  • (2) before_validation
  • (-) validate
  • (3) after_validation
  • (4) before_save
  • (5) before_create
  • (-) create
  • (6) after_create
  • (7) after_save
  • (8) after_transition
  • (-) end transaction (if enabled)
  • (9) after_commit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment