Skip to content

Instantly share code, notes, and snippets.

@Killavus
Created May 3, 2016 22:12
Show Gist options
  • Save Killavus/74b000394887a25c6a9c61695c6ab936 to your computer and use it in GitHub Desktop.
Save Killavus/74b000394887a25c6a9c61695c6ab936 to your computer and use it in GitHub Desktop.
class Customer < ActiveRecord::Base
after_create :send_welcome_email, unless: :auto_registered?
has_one :auto_created, dependent: :destroy
private
def send_welcome_email
CustomerMailer.welcome_email(self).deliver
end
def auto_registered?
!auto_created.nil?
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment