Skip to content

Instantly share code, notes, and snippets.

@tbprojects
Created August 3, 2015 13:25
Show Gist options
  • Save tbprojects/6c1979967ebdf17d71c3 to your computer and use it in GitHub Desktop.
Save tbprojects/6c1979967ebdf17d71c3 to your computer and use it in GitHub Desktop.
When order does matter...
# GOOD - check if can object be destroyed and when it's possible destroy associated objects :-)
before_destroy :can_be_removed?
has_many :custom_values, dependent: :destroy
# BAD - destroys associated objects and then check if object can be destroyed :-(
has_many :custom_values, dependent: :destroy
before_destroy :can_be_removed?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment