Skip to content

Instantly share code, notes, and snippets.

@bleonard
Created December 24, 2016 19:16
Show Gist options
  • Save bleonard/47d5faee7dc865cb3ebf62db6d47f2df to your computer and use it in GitHub Desktop.
Save bleonard/47d5faee7dc865cb3ebf62db6d47f2df to your computer and use it in GitHub Desktop.
class Task < ActiveRecord::Base
after_save :sync_with_external
def sync_with_external
response = External.sync!(id: self.id, info: self.info)
if response.error?
self.errors.add(:base, "There was a problem, etc ...")
raise ActiveRecord::RecordInvalid.new(self)
end
true # I still do this out of superstition
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment