Skip to content

Commit

Permalink
code for removing user
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelHoste committed Sep 6, 2018
1 parent b7d4e9f commit a8e8590
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/models/user.rb
Expand Up @@ -152,6 +152,13 @@ def admin?
self.f_id == ENV['FACEBOOK_ADMIN_ID'].to_i
end

def remove_from_application
LevelUserLink.where(:user_id => self.id).each { |lul| lul.update_attributes(:user_id => nil) }
PackUserLink.where(:user_id => self.id).destroy_all
UserUserLink.where(:user_id => self.id).destroy_all
self.destroy
end

# Ask facebook if this user likes the facebook fan page of the application
# return true or false
def request_like_fan_page?
Expand Down
8 changes: 8 additions & 0 deletions lib/tasks/app.rake
Expand Up @@ -49,5 +49,13 @@ namespace :app do
task :flush_cache => :environment do
Rails.cache.clear
end

task :delete_user => :environment do
user = User.where(:email => 'email').first
# or
user = User.where(:name => 'name').first

user.remove_from_application
end
end

0 comments on commit a8e8590

Please sign in to comment.