Heroku Guide - FaqiangMei/MHA-Survey-Portal GitHub Wiki

Heroku Guide

This page provides instructions for navigating Heroku, managing environment variables, switching user roles, and using the Heroku CLI for the Health project.


Navigating Heroku Dashboard

  1. Go to Heroku Dashboard.
  2. Select the Health project app from your list.
  3. Use the tabs (Overview, Resources, Deploy, Metrics, Activity, Access, Settings) to manage your app.

Managing Environment Variables

  1. In the Heroku Dashboard, go to your app.
  2. Click on the Settings tab.
  3. Reveal Config Vars to view or edit environment variables.
  4. Add, edit, or delete variables as needed (e.g., RAILS_MASTER_KEY, DATABASE_URL, custom flags).

Changing Role Access Flag (Quick Role Switch)

  • Some roles (admin, advisor, student) may be controlled by a flag in the database or as an environment variable.
  • To quickly switch a role flag (e.g., from 1 to 0):
    1. Open the Heroku Dashboard > Resources > click "Run Console" (or use Heroku CLI, see below).
    2. Run a Rails console command, e.g.:
      User.find_by(email: '[email protected]').update(role_flag: 1) # or 0
    3. Alternatively, update the flag via environment variable in Config Vars if your app uses ENV for roles.

Using the Heroku CLI

Installation

Common Commands

  • Login:
    heroku login
  • List apps:
    heroku apps
  • Open app dashboard:
    heroku open -a <app-name>
  • Run Rails console:
    heroku run rails console -a <app-name>
  • View logs:
    heroku logs --tail -a <app-name>
  • Set config var:
    heroku config:set VAR_NAME=value -a <app-name>
  • Get config vars:
    heroku config -a <app-name>

Tips

  • Always be careful when changing environment variables or role flags in production.
  • Use the CLI for advanced management and scripting.
  • For more, see the Heroku CLI documentation.
⚠️ **GitHub.com Fallback** ⚠️