Add admin user to ActiveAdmin - ruby-on-rails-4

I've recently uploaded my websapp to heroku.
When I was developing on Cloud9, I added admin user to ActiveAdmin.
The problem is that I was using sqlite in a development environment, but now using postgresql in a production environment, and so the admin data I added when using sqlite was deleted and cannot login as an admin.
I would like you to tell me how to add a new admin in a production environment.

You can create new user by directly through rails console using,
heroku run rails console --app <app name>
AdminUser.create(login: 'default_login', password: 'default_password')
I would rather suggest you to write seed.rb file containing default database insert to bootstart your application.

Related

Django Admin does not work after deployment Heroku

After deploying my application the admin of the website does not work. I am able to use the website, create an account and do all the crud, but the admin does not work.
1 - I created the superuser with
python manage.py createsuperuser
2 - I deployed and tried to access the admin
https://djangotodowoo.herokuapp.com/admin
Although, every time that I try to access this page it redirects to:
https://djangotodowoo.herokuapp.com/admin/login/?next=/admin/
I am not sure if that's the problem, but it's a hint at least.
This is happening because I have on my settings.py the following line
LOGIN_URL = '/login'
That checks if someone is trying to access a page without login and redirects to the login page.
I am not sure what the problem actually is, any ideas on how to solve the issue?
Thank you very much folks!
I found out that everything was working locally, the reason I was not able to log into the admin with my admin account is that I have to create a superuser on the Heroku side as well.
The solution was:
Create Heroku Super User
heroku run python manage.py createsuperuser

django postgres integration error, no such table - auth user

After updating the django settings.py default database to correct values.
i am able to run makemigrations and migrate command and also create super user. but when i login to the admin it gives me error of “no such table - auth user, OPERATIONAL ERROR”.
I noticed that even if i delete db.sqlite3 file, it comes back when i try to login, i think django looks for table in db.sqlite3 and not postgres.
why db.sqlite3 file re appear after deleting ?
how do i correctly configure my settings.py ?
i am integration using digitalocean managed database services with django installed in one droplet, i have integrated both preciously without error but i installed postgres, this is the first time using managed database service.
Thanks
It seems that your django settings are still pointing to the SQlite database.
Did you reload your WSGI process ? If not, the old SQlite settings are still used in memory.

redmine - restore admin user after a db:reset

I installed Redmine locally to practice configuring it. After a while, I ran
bundle exec rake db:reset db:migrate RAILS_ENV=production
to reset the database and start over. Now if I try to login, Redmine no longer has the default root user (user = admin, password = admin). This is the default user created during the initial install.
Should I have used some other way to clear the database that would have left me a Redmine admin user?
How do I now add an admin user to Redmine? I can access the MySql database by using the console.

What is my user and pass? Deploy django on AWS EC2 but can not login admin

I've followed this youtube instruction from amazon to deploy django web app to AWS EB EC2. The website successfully ran. But I can not login to admin. The admin that came with django polls example. I recall that during the setup process, it prompt me for RDS setup and since my web app use MySQL, I had to pick RDS setup. When I setup the RDS, it did not prompt me to create a user, but only prompted me to create a password, which dutifully I did.
https://www.youtube.com/watch?v=YJoOnKiSYws
Similar instructions can be found on AWS, too.
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_Python_django.html
I've tried username 'root' and password is 'blank' which works on my local pc, but of course that would make things too simple.
After that attempt failed, I did some searching in EC2 and RDS dashboard on AWS, and I found username=ebroot.
So I tried username 'ebroot' and password [rds_password_from_setup], but that didn't work.
I've tried many other combinations of usernames and passwords but nothing works. This might be a stupid question to ask the online community, but what do you suppose is my username and password that RDS might accept?
In order to create an admin user for my Django app on Beanstalk I created a custom Django command that I invoke in containers_commands, so there is no need for human input at all! Moreover I defined the user/password as environment variables so I can put my code under version control safely. The implementation of my command is something similar to this:
import os
from django.core.management.base import BaseCommand
from com.cygora.apps.users.models.User import User
class Command(BaseCommand):
def handle(self, *args, **options):
username = os.environ['SUPER_USER_NAME']
if not User.objects.filter(username=username).exists():
User.objects.create_superuser(username,
os.environ['SUPER_USER_EMAIL'],
os.environ['SUPER_USER_PASSWORD'])
then in my beanstalk config:
container_commands:
02_create_superuser_for_django_admin:
command: "python manage.py create_cygora_superuser"
leader_only: true
ps: if you never created a custom Django commands before, all you have to to is to create a package: management.commands in your desired app (ie: /your_project/your_app/management/commands/the_command.py), Django will load it automatically (and you can see it when typing python manage.py --help)

Restore heroku postgres password

How to recover a password for my heroku postgresql database? I used this command heroku pg:credentials DATABASE --reset but can't gain access to my django admin.
You can see your current credentials with heroku pg:credentials DATABASE or heroku config. You can then use the elements of the URL displayed to connect via a DB admin tool like Pgadmin. The password is the text between the : and the #.