From 720659cbe0f2e34bea9c64d11c4e4041d08ddbcf Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Wed, 27 Dec 2017 12:25:05 -0600 Subject: [PATCH] create content activators for new accounts --- app/models/user.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 0ea1ae15..57d7fb5b 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -59,6 +59,7 @@ class User < ActiveRecord::Base after_create :initialize_stripe_customer, unless: -> { Rails.env == 'test' } after_create :initialize_referral_code after_create :initialize_secure_code + after_create :initialize_content_type_activators def createable_content_types [Universe, Character, Location, Item, Creature, Race, Religion, Group, Magic, Language, Scene, Flora].select do |c| @@ -124,11 +125,17 @@ class User < ActiveRecord::Base end def initialize_referral_code - ReferralCode.create user: self, code: SecureRandom.uuid + ReferralCode.create(user: self, code: SecureRandom.uuid) end def initialize_secure_code - update secure_code: SecureRandom.uuid unless secure_code.present? + update(secure_code: SecureRandom.uuid) unless secure_code.present? + end + + def initialize_content_type_activators + [Universe, Character, Location, Item].each do |content_type| + user_content_type_activators.create(content_type: content_type.name) + end end def update_without_password(params, *options)