Soft deletes in Rails

Inspired by gist from DHH I bring you simple recipe for slightly more powerful soft deletes. Main feature is adding before_trash and after_trash callbacks by utilizing define_model_callbacks. Another nice-to-have is recording timestamp of deletion.

Recommended reading for this and another patterns for soft-deletes is Richard Dingwall’s article.

Filed under  //   callbacks   rails   soft deletes  

Comments [0]

About

Web developer. Visit my links. Follow me on twitter.