-1

I was trying to push a Rails app including active_admin to Heroku.

I expect to be able to log into Active Admin after pushing to Heroku

I have built a Rails app using active_admin. First I tried it on my localhost. I logged in with admin@example.com, set a new admin, and deleted the admin@example.com user. Then I pushed my app to GitHub and further to Heroku. I noticed Active Admin was not reachable on Heroku so I checked the logs and ran heroku rake db:migrate. Now I can switch to the login site at /admin but I cannot login. Neither with the admin@example.com nor my newly-created admin.

How can I fix this?

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
minennick
  • 91
  • 1
  • 1
  • 12
  • Fixed it with bypassing the authentication in the active_admin.rb – minennick Dec 10 '17 at 14:27
  • Why would you bypass authentication? How can that possibly be considered a solution? – ChrisGPT was on strike Dec 10 '17 at 15:24
  • 1
    @Chris i set config.current_user_method and config.authentication_method in the active_admin.rb to false. deployed it to heroku. Went in the admin interface and created a new admin. set the methods in the .rb back and deployed it again – minennick Dec 10 '17 at 21:52

2 Answers2

2

The only problem is that in the seeds.rb file, the line indicates only to be used if env = development. Here's exactly what it says:

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

In a production instance like Heroku, you'll have to use something like PSql, connect directly to the Heroku PG database for your instance, and create a user via query as this is the most secure way to do so.

etusm
  • 4,082
  • 1
  • 30
  • 26
0

When you deploy to Heroku your code gets updated on your dynos. Your database doesn't. Migrations must be run, e.g. via heroku run rake db:migrate or a release phase command, and any data you want must be created.

Whatever users you've configured on your development machine won't exist on Heroku. This is a good thing.

You should be able to add the default admin user by running heroku run rake db:seed using the Heroku CLI tool. Alternatively, you could run heroku run rails c and create a user interactively.

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257