1

I installed ActiveAdmin gem on an existing project, and I was able to Login on Localhost and following the documentation everything works perfectly on localhost. But on Heroku I can't login. After running heroku run rake db:seed I can't login with the usual.

Email: admin@example.com 
Password: password

I am getting the following error

Invalid Email or password.

Any Idea on how to fix this?

mayorsanmayor
  • 2,870
  • 4
  • 24
  • 44
  • Try `heroku run rake db:setup` – Mayur Shah Jul 21 '17 at 07:21
  • @MayurShah This didn't work, I got the following error. ` FATAL: permission denied for database "postgres" DETAIL: User does not have CONNECT privilege. Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "pool"=>5, "database"=>"d3rbq23ov7k6h2", "username"=>"wphrizjyufkvla", "password"=>"bb4c097cafda117b1b83288cb34f9a80e386ba846bbce8c7eda2afed6827287a", "port"=>5432, "host"=>"ec2-54-163-254-143.compute-1.amazonaws.com"} rake aborted! ` – mayorsanmayor Jul 21 '17 at 07:30
  • @puneet18 I answered the question. None of this was the problem and didn't fix it either. But thank you very much for your time and effort. – mayorsanmayor Jul 21 '17 at 08:18
  • @mayorsanmayor You should fix your issue of `heroku login` on your terminal. It helps you in future. – puneet18 Jul 21 '17 at 08:20
  • There was no issue with heroku login in the terminal actually. Try to create a new rails app and push it to heroku, then test some of the commands you know. You will notice that some priviledges have been removed for free users. – mayorsanmayor Jul 21 '17 at 08:22

3 Answers3

4

I got it to work. The problem was in the db/seed.rb file. Looks like Heroku removed access for free users to access the console from the terminal. So heroku run rake or rails console didn't work.

Earlier I didn't read the code in the seed file till the end. Here is it:

AdminUser.create!(email: 'admin@example.com', password: 'password', password_confirmation: 'password') if Rails.env.development?

This means the sample AdminUser created is meant to work only in development environment. It became a production environment the moment it was pushed on heroku. And since I cannot go into the rails console through Heroku. I had to add a new line in the seed file like so:

AdminUser.create!(email: 'admin@whateveryouwantyoursitetobe.com', password: 'SomePassword', password_confirmation: 'SomePassword') 

Now re-push this to heroku. And run heroku run rake db:seed

Now the new AdminUser details will work on your whateveryouwantyoursitetobe.com/admin

mayorsanmayor
  • 2,870
  • 4
  • 24
  • 44
0

Try this one

  1. heroku restart

  2. heroku pg:reset DATABASE or heroku pg:reset DATABASE_URL # resets the db

  3. heroku run rake db:setup

note: must specify DATABASE as above,You don't need to worry about DATABASE_URL (it's an environment variable set on Heroku)

Mayur Shah
  • 3,344
  • 1
  • 22
  • 41
  • 1 - 2 worked, even destroyed my database, but the 3rd still didn't work. Got the same error as before: PG::ConnectionBad: FATAL: permission denied for database "postgres" DETAIL: User does not have CONNECT privilege. – mayorsanmayor Jul 21 '17 at 07:52
  • what about `heroku run rake db:create` and `heroku run rake db:migrate` – Mayur Shah Jul 21 '17 at 07:54
  • @mayorsanmayor try this command as well `rake db:schema:load` – Mayur Shah Jul 21 '17 at 08:03
  • I answered the question. None of this was the problem and didn't fix it either. But thank you very much for your time and effort. – mayorsanmayor Jul 21 '17 at 08:19
0

Have You try This after push to heroku???

heroku run rake db:create

 heroku run rake db:migrate
Ronak Bhatt
  • 113
  • 1
  • 2
  • 14