Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# app/models/user.rb
class User < ActiveRecord::Base
include UserObserver
has_many :galleries
end
# /app/models/concerns/user_observer.rb
module UserObserver
extend ActiveSupport::Concern
included do
after_create :create_default_gallery, :send_welcome_email
end
private
def create_default_gallery
galleries.create(name: "Default gallery")
end
def send_welcome_email
UserMailer.delay.welcome(id)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.