add option in settings to delete account

This commit is contained in:
Joshua Arts
2018-07-27 11:36:28 -04:00
parent f285377abf
commit 5e5f31c375
7 changed files with 75 additions and 1 deletions

View File

@ -4,6 +4,8 @@ class User < ApplicationRecord
after_create :initialize_main_room
before_save { email.try(:downcase!) }
before_destroy :destroy_rooms
has_many :rooms
belongs_to :main_room, class_name: 'Room', foreign_key: :room_id, required: false
@ -83,6 +85,11 @@ class User < ApplicationRecord
private
# Destory a users rooms when they are removed.
def destroy_rooms
rooms.destroy_all
end
# Initializes a room for the user and assign a BigBlueButton user id.
def initialize_main_room
self.uid = "gl-#{(0...12).map { (65 + rand(26)).chr }.join.downcase}"