Created
May 26, 2014 08:57
-
-
Save romanonthego/5779e1b5cca59e82306b to your computer and use it in GitHub Desktop.
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
# You could do it before, after save or in any place you want | |
before_save do | |
file = self.file #or group, or that ever your attribute is called | |
# it is important to wrap it up in case remote call fails for any reason | |
begin | |
response = file.copy true, "#{target}" | |
# { | |
# "url" : "http://..." | |
# } | |
# do that you must. it is basicly JSON string. | |
rescue | |
# in case everything fails. | |
# it is not happens very ofter but your application can not depends on server status of any other server, right? | |
# you may put it to query to call again in five minutes in separate process for example | |
logger.error "#{error text}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment