Skip to content

Instantly share code, notes, and snippets.

@romanonthego
Created May 26, 2014 08:57
Show Gist options
  • Save romanonthego/5779e1b5cca59e82306b to your computer and use it in GitHub Desktop.
Save romanonthego/5779e1b5cca59e82306b to your computer and use it in GitHub Desktop.
# 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