Skip to content

Instantly share code, notes, and snippets.

@edgar
Created September 12, 2011 20:31
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 edgar/1212319 to your computer and use it in GitHub Desktop.
Save edgar/1212319 to your computer and use it in GitHub Desktop.
class Photo
include Mongoid::Document
include Mongoid::Timestamps
referenced_in :stream
set_callback(:destroy, :after) do |document|
document.update_stream
end
def update_stream
stream.decrement_number_of_pictures
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment