Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kivanio/bc95160cf20bc9922a93b6f335213bce to your computer and use it in GitHub Desktop.
Save kivanio/bc95160cf20bc9922a93b6f335213bce to your computer and use it in GitHub Desktop.
class Customer < ActiveRecord::Base
has_one :auto_created, dependent: :destroy
def self.register(params)
new(params).tap do |customer|
customer.save!
customer.send_welcome_email
end
end
def self.auto_create(params)
new(params).tap do |customer|
customer.save!
end
end
def send_welcome_email
CustomerMailer.welcome_email(self).deliver
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment