momchenr
momchenr

Reputation: 275

Rails, Devise, Heroku deleting user account from Console

I have some empty user accounts sitting in my production environment that I made as a test, that I'd like to delete now. They don't have any items that are attached to them, so what command do I run from the heroku console to delete these? Also, I access the heroku console by just typing 'heroku console', right?

I deleted the "User Delete" button from the devise view because I didn't want users to be able to delete their accounts... Figured this was the cleanest way.

Upvotes: 2

Views: 1048

Answers (2)

ahartami
ahartami

Reputation: 19

I went to Heroku console by typing this:

heroku run rails c

Just in case, you want to delete a certain user like me, you can use this command where id is the id of the user.

User.find_by!(id: 6).destroy!

Upvotes: 0

pjam
pjam

Reputation: 6356

It seems like the easiest way is to open a heroku console and delete manually each user you want to delete. I would advise you to be extremely careful since it is a production environment.

heroku run console -a <YOUR APP NAME>
User.find(list_of_ids).destroy_all

Upvotes: 6

Related Questions