Skip to content

Instantly share code, notes, and snippets.

@kidpollo
Created February 27, 2013 10:23
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 kidpollo/5046927 to your computer and use it in GitHub Desktop.
Save kidpollo/5046927 to your computer and use it in GitHub Desktop.
df
class Post < ActiveRecord::Base
after_save PostCallbacks.new
end
class PostCallbacks
def after_save(post)
Rails.queue.push(PostNotification.new(post_id,'save'))
end
end
class PostNotification
def initialize(post_id, action)
@post = Post.find(post_id)
@action = action
end
def run
case @action
when 'create'
...
when 'save'
...
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment