Search code examples
ruby-on-railsrubymodel-view-controllerherokuadmin

Set admin user for production rails app


I have a rails app that I want to set an administrative user for.

When I did this on my local machine I just went into the console and set User.admin = true and then saved the record.

Now I have my app on Heroku and I tried to pull my database using the command:

heroku pg:pull HEROKU_POSTGRESQL_quotes_app mylocaldb --app quotesappp

In this situation quotesapp is my db and quotesappp is my app name on Heroku. When I do this thought, I am met with this error:

Unknown database: HEROKU_POSTGRESQL_quotes_app. Valid options are: DATABASE_URL

I got the db name quotesapp from my yml file under production.

database.yml:

production:
  <<: *default
  database: quotes_app

My idea here was to pull the DB to local, set the admin user, and push it back to production. Does anyone see why I am getting that error? Or could you suggest a better way of doing this?


Solution

  • Just run rails console on the Heroku app.

    heroku run rails console -a <my-heroku-app-name>
    

    Or, if you have a single heroku app, simply run

    heroku run console