Skip to content

Instantly share code, notes, and snippets.

@PerezIgnacio
Last active February 4, 2020 18:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PerezIgnacio/8af85c58f0073abffce46091a28f3ff3 to your computer and use it in GitHub Desktop.
Save PerezIgnacio/8af85c58f0073abffce46091a28f3ff3 to your computer and use it in GitHub Desktop.
User example with callbacks
class User < ApplicationRecord
after_create :send_to_crm, if :send_user_to_crm?
after_create :send_welcome_email, if -> { receive_email_notifications: true }
# ...
private
def send_to_crm
# ...
end
def send_user_to_crm?
# ...
end
def send_welcome_email
# ...
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment