Skip to content

Instantly share code, notes, and snippets.

@kylewelsby
Created October 2, 2011 14:49
Show Gist options
  • Save kylewelsby/1257514 to your computer and use it in GitHub Desktop.
Save kylewelsby/1257514 to your computer and use it in GitHub Desktop.
Push Hook
class Application < ActiveRecord::Base
require 'httparty'
...
def push_message(message)
if self.post_url
post(self.post_url, :body => message)
end
end
end
class Message < ActiveRecord::Base
belongs_to :user
after_create :push_to_applications
private
def push_to_applications
user.applications.each do |app|
app.push_message(self)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment