Skip to content

Instantly share code, notes, and snippets.

@djensen47
Created September 22, 2013 21:07
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 djensen47/6663814 to your computer and use it in GitHub Desktop.
Save djensen47/6663814 to your computer and use it in GitHub Desktop.
This is a Discourse plugin to enable dice rolling. Version one may not work and is a work in progress.
# file: plugins/dicecourse/observers/post_dice_observer.rb
class PostDiceObserver < ActiveRecord::Observer
observe :post
def after_create(model)
Rails.logger.debug "After Create on Post triggered"
#roll some dice
end
end
# file: plugins/dicecourse/plugin.rb
# name: dicecourse
# about: A plugin to roll dice
# version: 0.1
# authors: Dave Jensen
after_initialize do
config.load_paths << "#{RAILS_ROOT}/plugins/dicecourse/observers"
config.active_record.observers << :plugin_post_observer
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment