Created
October 2, 2011 14:49
-
-
Save kylewelsby/1257514 to your computer and use it in GitHub Desktop.
Push Hook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Application < ActiveRecord::Base | |
require 'httparty' | |
... | |
def push_message(message) | |
if self.post_url | |
post(self.post_url, :body => message) | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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