Ruby on Rail users how to reset email for admin login

May 22, 2014 1.3k views
I can't contact web person who set up site. I logged in admin using email and password to make a change on site. Not knowing anything I mistakenly deleted my email address which was the one I used to log on to admin . I believe my web guy used Rudy on Rails for the admin application. I need someone familiar with Ruby to help me reset my email for admin so I can get back into site. Certain many parts of website were custom made. the site is using Digital Ocean.
4 Answers
Hi Steve,

Sorry to hear that you still haven't figured this out. What was the result of you last efforts?

It looks like your site uses ActiveAdmin for it administration panel. Since you still have access to the server, you should be able add a new admin user through the rails console. If you login to the server directly, change to the directory holding the rails project and run:


rails console


You should now be in the rails console. Here you can create a new
admin user by running:


u=AdminUser.new(:email => "YOUR_EMAIL", :password => 'YOUR_NEW_PASSWORD', :password_confirmation => 'YOUR_NEW_PASSWORD')
u.save
Steve,

I've deleted your comment as you include credentials that you should keep confidential. I'll include the rest of your comment below:

--------

Andrew : I have had two suggestions for fixing this problem . Problem for me I have zero understanding of the technology and am afraid to screw things up more.
Below is the first recommendation from support at Digital Ocean :
If you login to the server directly, change to the directory holding
the rails project and run:

rails console

You should not be in the rails console. Here you can create a new
admin user by running:

u=AdminUser.new(:email => "admin@example.com", :password =>
'password', :password_confirmation => 'password')
u.save

The second is this :
Someone tried without success , this is the statement “there was a deeper problem having to do with the database not communicating with the site.” Below is the Chat with his explanation
CHAT:
luke: when you ssh in, do you do so as root?
me: yes
luke: causei got a big error when i did rails console
me: oh
maybe I did too but didn't recognize
luke: "`connect': Access denied for user 'root'@'localhost' (using p ..."
which basically means it cant connect to mysql database
and if thats the case then i cant do anything w the db
me: it let me in as far as I can see.
luke: can you prove the db is running?
is the site using it?
me: only in as much as the last time I looked the site was working
luke: so what we need to do is figure out what the login for mysql is
and why he ruby gem is failing when we try to run console
its werid that the site is working
me: unless it's the same, I doun't have it
luke: does the site pull from the database on every page?
can you send me a url
me: the url is smallbusinesscongress.org
i don't know
luke: in the app there is a file
config/databse.yml
this has the configuration details for the db
like how to login etc
it says 'username' xxxxxxxx
and pw XXXXXXXXXXXXXXXX
so im going to see if i can connect directly to mysql
using that combo
me: okay
luke: ok so
here is what i think the problem is
we cant connect to mysql
me: okay
luke: and im not sure why the site is not having the same problem...
in order to connect to the mysql db we will need a valid user to be created or the root password reset.
so who ever set up the server ( not necc, the site) or is administering it now
should help with that
so if there is a Host company, you may be able to contact them
luke: or maybe they have a control panel that you can access and make the changes
luke: Digital ocean is the host i think
https://dazzlepod.com/ip/208.68.36.171/#whois
give them a call
luke: if you tell them your root pw they might help you
or you can just ask them if they have a control panbel
Andrew , thank you , as I made clear , this is all Greek to me.
I just want to log on to my site . If I can't do it then I have no option but shut it down and begin again. There are things on the site that need cancelled and
updated . Any suggestions?
@Steve: I'll email you directly. I think I've got this figured out for you.
Have another answer? Share your knowledge.