Getting Started on Heroku with Ruby
Introduction
Complete this tutorial to deploy a sample Ruby app to Cedar, the legacy generation of the Heroku platform. To deploy the app to the Fir generation, only available to Heroku Private Spaces, follow this guide instead.
The tutorial assumes that you have:
- A verified Heroku Account
- An Eco dynos plan subscription (recommended)
- Ruby 3.4.9 installed locally - see the installation guides for Ruby and Rails on macOS, Windows, and Linux
- Bundler installed locally - run
gem install bundler - Postgres installed locally
Using dynos and databases to complete this tutorial counts towards your usage. We recommend using our low-cost plans to complete this tutorial. Eligible students can apply for platform credits through our new Heroku for GitHub Students program.
Set Up
Install the Heroku Command Line Interface (CLI). Use the CLI to manage and scale your app, provision add-ons, view your logs, and run your app locally.
The Heroku CLI requires Git, the popular version control system. If you don’t already have Git installed, complete the following before proceeding:
Download and run the installer for your platform:
Download the appropriate installer for your Windows installation:
You can find more installation options for the Heroku CLI here.
After installation, you can use the heroku command from your command shell.
To log in to the Heroku CLI, use the heroku login command:
$ heroku login
heroku: Press any key to open up the browser to login or q to exit:
Opening browser to https://cli-auth.heroku.com/auth/cli/browser/***
heroku: Waiting for login...
Logging in... done
Logged in as me@example.com
This command opens your web browser to the Heroku login page. If your browser is already logged in to Heroku, click the Log In button on the page.
This authentication is required for the heroku and git commands to work correctly.
If you have any problems installing or using the Heroku CLI, see the main Heroku CLI article for advice and troubleshooting steps.
If you’re behind a firewall that uses a proxy to connect with external HTTP/HTTPS services, set the HTTP_PROXY or HTTPS_PROXY environment variables in your local development environment before running the heroku command.
Clone the Sample App
If you’re new to Heroku, it’s recommended that you complete this tutorial using the Heroku-provided sample application.
To deploy an existing application, follow this article instead.
Clone the sample application to get a local version of the code. Execute these commands in your local command shell or terminal:
$ git clone https://github.com/heroku/ruby-getting-started.git
$ cd ruby-getting-started
You now have a functioning Git repository that contains a simple application. It includes a Gemfile file, which Ruby’s dependency manager, bundler, uses to install dependencies.
Create Your App
Using a dyno and a database to complete this tutorial counts towards your usage. Delete your app, and database as soon as you’re done to control costs.
By default, apps use Eco dynos if you’re subscribed to Eco. Otherwise, it defaults to Basic dynos. The Eco dynos plan is shared across all Eco dynos in your account. It’s recommended if you plan on deploying many small apps to Heroku. Learn more here. Eligible students can apply for platform credits through our Heroku for GitHub Students program.
Create an app on Heroku to prepare the platform to receive your source code:
$ heroku create --stack heroku-26
Creating app... done, fierce-lake-02376, stack is heroku-26
https://fierce-lake-02376-ebb301b5b365.herokuapp.com/ | https://git.heroku.com/fierce-lake-02376.git
When you create an app, a Git remote named heroku is also created and added to your local repository configuration. Git remotes are versions of your repository that live on other servers. You can deploy your app by pushing code to that special Heroku-hosted remote associated with your app.
Heroku generates a random name for your app, in this case, fierce-lake-02376. You can specify your own app name.
Provision a Database
The sample app uses a database. Provision a Heroku Postgres database, an add-on available through the Elements Marketplace. Add-ons are cloud services that provide out-of-the-box additional services for your application, such as logging, monitoring, databases, and more.
An essential-0 Postgres size costs $5 a month, prorated to the minute. At the end of this tutorial, we prompt you to delete your app and its database to minimize costs.
$ heroku addons:create heroku-postgresql:essential-0
Creating heroku-postgresql:essential-0 on fierce-lake-02376... ~$0.007/hour (max $5/month)
Database should be available soon
postgresql-globular-93680 is being created in the background. The app will restart when complete...
Run heroku addons:info postgresql-globular-93680 to check creation progress.
Run heroku addons:docs heroku-postgresql to view documentation.
You can wait for the database to provision by running this command:
$ heroku pg:wait
After that command exits, your Heroku app can access the Postgres database. The DATABASE_URL environment variable stores your credentials, which your app is configured to connect to. You can see all the add-ons provisioned with the addons command:
$ heroku addons
Add-on Plan Price Max Price State
----------------------------------------------------------------------------------------------
heroku-postgresql (postgresql-globular-93680) essential-0 ~$0.007/hour $5/month created
└─ as DATABASE
The table above shows add-ons and the attachments to the current app (fierce-lake-02376) or other apps.
Deploy the App
Deploy your code. This command pushes the main branch of the sample repo to your heroku remote, which then deploys to Heroku:
$ git push heroku main
remote: Updated 102 paths from 6ef97af
remote: Compressing source files... done.
remote: Building source:
remote: Waiting on build...
remote: Waiting on build... (elapsed: 13s)
remote: Waiting on build... (elapsed: 24s)
remote:
remote: -----> Building on the Heroku-26 stack
remote: -----> Determining which buildpack to use for this app
remote: -----> Ruby app detected
remote:
remote: ###### WARNING:
remote:
remote: Your app has a `bin/bundle` binstub that may cause bundler to
remote: malfunction. We recommend you remove it.
remote:
remote: When `bin/bundle` is present, `bundle clean` may remove the
remote: installed version of bundler and then your app falls back to
remote: the default bundler version that ships with Ruby, which can be
remote: a different major version than expected.
remote:
remote: To fix this issue, run:
remote:
remote: ```
remote: $ rm bin/bundle
remote: $ git add .
remote: $ git commit -m "Remove bin/bundle binstub"
remote: ```
remote:
remote: For more information see:
remote: https://github.com/heroku/heroku-buildpack-ruby/issues/1690
remote:
remote: -----> Using Ruby version: ruby-3.4.9
remote: -----> Installing bundler 4.0.5
remote: -----> Installing dependencies using bundler 4.0.5
remote: Running: BUNDLE_WITHOUT='development:test' BUNDLE_PATH=vendor/bundle BUNDLE_BIN=vendor/bundle/bin BUNDLE_DEPLOYMENT=1 bundle install -j4
remote: Fetching gem metadata from https://rubygems.org/.........
remote: Fetching rake 13.4.2
remote: Installing rake 13.4.2
remote: Fetching base64 0.3.0
remote: Fetching bigdecimal 4.1.3
remote: Fetching concurrent-ruby 1.3.8
remote: Fetching connection_pool 3.0.2
remote: Installing base64 0.3.0
remote: Fetching drb 2.2.3
remote: Installing bigdecimal 4.1.3 with native extensions
remote: Installing connection_pool 3.0.2
remote: Installing drb 2.2.3
remote: Fetching json 3.0.2
remote: Fetching logger 1.7.0
...
remote:
remote: ###### WARNING:
remote:
remote: Your app has a `bin/bundle` binstub that may cause bundler to
remote: malfunction. We recommend you remove it.
remote:
remote: When `bin/bundle` is present, `bundle clean` may remove the
remote: installed version of bundler and then your app falls back to
remote: the default bundler version that ships with Ruby, which can be
remote: a different major version than expected.
remote:
remote: To fix this issue, run:
remote:
remote: ```
remote: $ rm bin/bundle
remote: $ git add .
remote: $ git commit -m "Remove bin/bundle binstub"
remote: ```
remote:
remote: For more information see:
remote: https://github.com/heroku/heroku-buildpack-ruby/issues/1690
remote:
remote: ###### WARNING:
remote:
remote: There is a more recent Ruby version available for you to use:
remote:
remote: 3.4.11
remote:
remote: The latest version will include security and bug fixes. We always recommend
remote: running the latest version of your minor release.
remote:
remote: Please upgrade your Ruby version.
remote:
remote: For all available Ruby versions see:
remote: https://devcenter.heroku.com/articles/ruby-support#supported-runtimes
remote:
remote:
remote: -----> Discovering process types
remote: Procfile declares types -> web
remote: Default types for buildpack -> console, rake
remote:
remote: -----> Compressing...
remote: Done: 57.7M
remote: -----> Launching...
remote: Released v4
remote: https://fierce-lake-02376-ebb301b5b365.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/fierce-lake-02376.git
* [new branch] main -> main
Visit the app at the URL shown in the logs. As a shortcut, you can also open the website as follows:
$ heroku open
Understanding the Procfile
Use a Procfile, a text file in the root directory of your application, to explicitly declare what command to execute to start your app.
The Procfile in the example app looks like this:
web: bundle exec puma -C config/puma.rb
This Procfile declares a single process type, web, and the command needed to run it. The name web is important here. It declares that this process type is attached to Heroku’s HTTP routing stack and receives web traffic when deployed. The command used here runs Puma, the web server, and passes in a configuration file.
A Procfile can contain additional process types. For example, you can declare a background worker process that processes items off a queue.
View Logs
Heroku treats logs as streams of time-ordered events, aggregated from the output streams of all your app and Heroku components. Heroku provides a single stream for all events.
View information about your running app by using one of the logging commands, heroku logs --tail:
$ heroku logs --tail
2026-10-16T12:35:10.032505+00:00 heroku[web.1]: Starting process with command `bundle exec puma -C config/puma.rb`
2026-10-16T12:35:11.016788+00:00 app[web.1]: [2] Puma starting in cluster mode...
2026-10-16T12:35:11.016803+00:00 app[web.1]: [2] * Puma version: 8.0.2 ("Into the Arena")
2026-10-16T12:35:11.016803+00:00 app[web.1]: [2] * Ruby version: ruby 3.4.9 (2026-03-11 revision 76cca827ab) +PRISM [x86_64-linux]
2026-10-16T12:35:11.016803+00:00 app[web.1]: [2] * Min threads: 3
2026-10-16T12:35:11.016804+00:00 app[web.1]: [2] * Max threads: 3
2026-10-16T12:35:11.016819+00:00 app[web.1]: [2] * Environment: production
2026-10-16T12:35:11.016827+00:00 app[web.1]: [2] * Master PID: 2
2026-10-16T12:35:11.016835+00:00 app[web.1]: [2] * Workers: 2
2026-10-16T12:35:11.016851+00:00 app[web.1]: [2] * Restarts: (✔) hot (✖) phased (✖) refork
2026-10-16T12:35:11.016851+00:00 app[web.1]: [2] * Preloading application
2026-10-16T12:35:12.937442+00:00 app[web.1]: [2] * Listening on http://[::]:18839
2026-10-16T12:35:12.937521+00:00 app[web.1]: [2] Use Ctrl-C to stop
2026-10-16T12:35:12.944872+00:00 app[web.1]: [2] - Worker 0 (PID: 7) booted in 0.0s, phase: 0
2026-10-16T12:35:12.946920+00:00 app[web.1]: [2] - Worker 1 (PID: 11) booted in 0.0s, phase: 0
2026-10-16T12:35:12.995393+00:00 heroku[web.1]: State changed from starting to up
2026-10-16T12:35:32.672397+00:00 app[web.1]: source=rack-timeout id=683d134a-8c92-d3fd-b699-b0bef2ad829c wait=5ms timeout=15000ms state=ready
2026-10-16T12:35:32.674267+00:00 app[web.1]: [683d134a-8c92-d3fd-b699-b0bef2ad829c] Started GET "/" for 20.29.157.48 at 2026-10-16 12:35:32 +0000
2026-10-16T12:35:32.677978+00:00 app[web.1]: [683d134a-8c92-d3fd-b699-b0bef2ad829c] Processing by WelcomeController#index as */*
2026-10-16T12:35:32.689455+00:00 app[web.1]: [683d134a-8c92-d3fd-b699-b0bef2ad829c] Rendered layout layouts/application.html.erb (Duration: 6.5ms | GC: 0.0ms)
2026-10-16T12:35:32.689852+00:00 app[web.1]: [683d134a-8c92-d3fd-b699-b0bef2ad829c] Completed 200 OK in 12ms (Views: 8.2ms | ActiveRecord: 0.0ms (0 queries, 0 cached) | GC: 0.2ms)
2026-10-16T12:35:32.691399+00:00 app[web.1]: [683d134a-8c92-d3fd-b699-b0bef2ad829c] source=rack-timeout id=683d134a-8c92-d3fd-b699-b0bef2ad829c wait=5ms timeout=15000ms service=20ms state=completed
2026-10-16T12:35:32.692462+00:00 heroku[router]: at=info method=GET path="/" host=fierce-lake-02376-ebb301b5b365.herokuapp.com request_id=683d134a-8c92-d3fd-b699-b0bef2ad829c fwd="123.456.789.0" dyno=web.1 connect=0ms service=24ms status=200 bytes=9152 protocol=http2.0 tls=true tls_version=tls1.3
To generate more log messages, refresh the app in your browser.
To stop streaming the logs, press Control+C.
Scale the App
After deploying the sample app, it automatically runs on a single web dyno. Think of a dyno as a lightweight container that runs the command specified in the Procfile.
You can check how many dynos are running by using the ps command:
$ heroku ps
=== web (Basic): bundle exec puma -C config/puma.rb (1)
web.1: up 2026/10/16 12:35:12 +0000 (~ 44s ago)
Scaling an app on Heroku is equivalent to changing the number of running dynos. Scale the number of web dynos to zero:
$ heroku ps:scale web=0
$ heroku ps:wait
Access the app again by hitting refresh in your browser, or heroku open to open it in a web tab. You get an error message because you no longer have web dynos available to serve requests.
Scale it up again:
$ heroku ps:scale web=1
$ heroku ps:wait
By default, apps use Eco dynos if you’re subscribed to Eco. Otherwise, it defaults to Basic dynos. The Eco dynos plan is shared across all Eco dynos in your account and is recommended if you plan on deploying many small apps to Heroku. Eco dynos sleep if they don’t receive any traffic for half an hour. This sleep behavior causes a few seconds delay for the first request upon waking. Eco dynos consume from a monthly, account-level quota of eco dyno hours. As long as you haven’t exhausted the quota, your apps can continue to run.
To avoid dyno sleeping, upgrade to a Basic or higher dyno type as described in the Dyno Types article. Upgrading to at least Standard dynos allows you to scale up to multiple dynos per process type.
Declare App Dependencies
Heroku recognizes an app as a Ruby app by the existence of a Gemfile file in the root directory.
The demo app you deployed already has a Gemfile:
source 'https://rubygems.org'
ruby '>= 3.2', '< 4.0'
# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem "rails", "~> 8.1.2"
# The modern asset pipeline for Rails [https://github.com/rails/propshaft]
gem "propshaft"
# Use postgresql as the database for Active Record
gem 'pg', '~> 1.6.3'
# Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails]
gem "importmap-rails"
...
The Gemfile file specifies the dependencies to install with your application. It also determines the version of Ruby used to run your application on Heroku.
When an app deploys, Heroku reads this file and installs the appropriate Ruby version and dependencies using the bundle install command.
To run the app locally, you must also install dependencies locally. This Gemfile dependency pg only resolves if you have Postgres installed locally. Install Postgres before you proceed.
If the command which psql returns some value on your command line, you have Postgres installed locally:
$ which psql
/usr/local/bin/psql
Run bundle install in your local directory to install the dependencies, preparing your system for running the app locally:
$ bundle install
Bundler 2.6.9 is running, but your lockfile was generated with 4.0.5. Installing Bundler 4.0.5 and restarting using that version.
Fetching gem metadata from https://rubygems.org/.
Fetching bundler 4.0.5
Installing bundler 4.0.5
Fetching gem metadata from https://rubygems.org/.........
After installing dependencies, you can run your app locally.
Run the App Locally
The sample app uses a database, so you must create the database and table locally using the rake task:
$ bundle exec rake db:create db:migrate db:migrate:status
Created database 'ruby-getting-started_development'
Created database 'ruby-getting-started_test'
database: ruby-getting-started_development
Status Migration ID Migration Name
--------------------------------------------------
up 20140707111715 Create widgets
Now start your application locally using the heroku local command:
$ heroku local web --port=5006
[OKAY] Loaded ENV .env File as KEY=VALUE Format
12:40:46 PM web.1 | [228889] Puma starting in cluster mode...
12:40:47 PM web.1 | [228889] * Puma version: 8.0.2 ("Into the Arena")
12:40:47 PM web.1 | [228889] * Ruby version: ruby 3.4.9 (2026-03-11 revision 76cca827ab) +PRISM [x86_64-linux]
12:40:47 PM web.1 | [228889] * Min threads: 3
12:40:47 PM web.1 | [228889] * Max threads: 3
12:40:47 PM web.1 | [228889] * Environment: development
12:40:47 PM web.1 | [228889] * Master PID: 228889
12:40:47 PM web.1 | [228889] * Workers: 2
12:40:47 PM web.1 | [228889] * Restarts: (✔) hot (✖) phased (✖) refork
12:40:47 PM web.1 | [228889] * Preloading application
12:40:47 PM web.1 | [228889] * Listening on http://[::1]:5006
12:40:47 PM web.1 | [228889] Use Ctrl-C to stop
12:40:47 PM web.1 | [228889] - Worker 0 (PID: 228965) booted in 0.01s, phase: 0
12:40:47 PM web.1 | [228889] - Worker 1 (PID: 228972) booted in 0.0s, phase: 0
Just like Heroku, heroku local uses the Procfile to know what command to execute.
To see your app running locally, open http://localhost:5006 with your web browser.
To stop the app from running locally, in the CLI, press Control + C to exit.
Push Local Changes
In this step, you propagate a local change to the application to Heroku.
Modify Gemfile to include an additional dependency for the cowsay gem.
In file Gemfile, on line 4 add:
gem "cowsay"
The file now looks like this:
source 'https://rubygems.org'
ruby '>= 3.2', '< 4.0'
gem "cowsay"
# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
...
Modify app/views/welcome/index.erb to use the cowsay gem.
At the end of app/views/welcome/index.erb add:
<pre><%= Cowsay.say("Hello", "tux") %></pre>
Now test locally:
$ bundle install
$ heroku local --port=5006
Visit your application at http://localhost:5006. If your changes worked, you see a cute ASCII picture displayed.
Now deploy this local change to Heroku.
Almost every deploy to Heroku follows this same pattern. First, add the modified files to the local Git repository:
$ git add .
Now commit the changes to the repository:
$ git commit -m "Added cowsay gem"
[main afb62a8] Added cowsay gem
3 files changed, 4 insertions(+), 5 deletions(-)
Now deploy as before:
$ git push heroku main
Finally, check that everything is working:
$ heroku open
Provision a Logging Add-on
Add-ons are third-party cloud services that provide out-of-the-box additional services for your application, from persistence through logging to monitoring and more.
By default, Heroku stores 1500 lines of logs from your application, but the full log stream is available as a service. Several add-on providers have logging services that provide things such as log persistence, search, and email and SMS alerts.
In this step, you provision one of these logging add-ons, Papertrail, using its free plan.
Provision the Papertrail logging add-on:
$ heroku addons:create papertrail
Creating papertrail on fierce-lake-02376... free
Provisioning has been successful
Created papertrail-shallow-01846
Run heroku addons:docs papertrail to view documentation.
The add-on is now deployed and configured for your app. You can list add-ons for your app with this command:
$ heroku addons
Add-on Plan Price Max Price State
----------------------------------------------------------------------------------------------
heroku-postgresql (postgresql-globular-93680) essential-0 ~$0.007/hour $5/month created
└─ as DATABASE
papertrail (papertrail-shallow-01846) choklad free free created
└─ as PAPERTRAIL
The table above shows add-ons and the attachments to the current app (fierce-lake-02376) or other apps.
To see this particular add-on in action, visit your application’s Heroku URL a few times. Each visit generates more log messages, which get routed to the Papertrail add-on. Visit the Papertrail console to see the log messages:
$ heroku addons:open papertrail
Your browser opens up a Papertrail web console, showing the latest log events. The interface lets you search and set up alerts.
Start a Console
You can run a command, typically scripts and applications that are part of your app, in a one-off dyno using the heroku run command. You can also run an interactive bash session in your app’s environment:
$ heroku run bash
Running bash on fierce-lake-02376... starting, run.9107
Running bash on fierce-lake-02376... connecting, run.9107
Running bash on fierce-lake-02376... up, run.9107
~ $ ruby -v
ruby 3.4.9 (2026-03-11 revision 76cca827ab) +PRISM [x86_64-linux]
~ $ rails -v
Rails 8.1.4
~ $ ls -lah
total 116K
drwx------ 15 u55478 dyno 4.0K Oct 16 12:41 .
drwxr-xr-x 11 root root 4.0K Oct 7 22:07 ..
-rw------- 1 u55478 dyno 9 Oct 16 12:33 .env
drwx------ 2 u55478 dyno 4.0K Oct 16 12:33 .github
-rw------- 1 u55478 dyno 577 Oct 16 12:33 .gitignore
drwx------ 3 u55478 dyno 4.0K Oct 16 12:35 .heroku
drwx------ 2 u55478 dyno 4.0K Oct 16 12:35 .profile.d
-rw------- 1 u55478 dyno 5.0K Oct 16 12:33 CODE_OF_CONDUCT.md
-rw------- 1 u55478 dyno 1.1K Oct 16 12:33 Gemfile
-rw------- 1 u55478 dyno 5.7K Oct 16 12:33 Gemfile.lock
-rw------- 1 u55478 dyno 1.2K Oct 16 12:33 LICENSE
-rw------- 1 u55478 dyno 40 Oct 16 12:33 Procfile
-rw------- 1 u55478 dyno 3.0K Oct 16 12:33 README.md
-rw------- 1 u55478 dyno 249 Oct 16 12:33 Rakefile
-rw------- 1 u55478 dyno 407 Oct 16 12:33 SECURITY.md
drwx------ 9 u55478 dyno 4.0K Oct 16 12:33 app
-rw------- 1 u55478 dyno 281 Oct 16 12:33 app.json
drwx------ 2 u55478 dyno 4.0K Oct 16 12:34 bin
drwx------ 5 u55478 dyno 4.0K Oct 16 12:33 config
-rw------- 1 u55478 dyno 154 Oct 16 12:33 config.ru
drwx------ 3 u55478 dyno 4.0K Oct 16 12:33 db
drwx------ 4 u55478 dyno 4.0K Oct 16 12:33 lib
drwx------ 2 u55478 dyno 4.0K Oct 16 12:33 log
drwx------ 3 u55478 dyno 4.0K Oct 16 12:35 public
drwx------ 8 u55478 dyno 4.0K Oct 16 12:33 test
drwx------ 4 u55478 dyno 4.0K Oct 16 12:35 tmp
drwx------ 6 u55478 dyno 4.0K Oct 16 12:34 vendor
~ $ exit
exit
If you receive an error, Error connecting to process, configure your firewall.
Type exit to exit the shell. You can run any command this way such as rails console or rake db:migrate.
Define Config Vars
Heroku lets you externalize configuration by storing data such as encryption keys or external resource addresses in config vars.
At runtime, we expose config vars as environment variables to the application.
For example, modify app/views/welcome/index.erb so that the method repeats an action depending on the value of the TIMES environment variable. Change the file so that its first few lines read as follows:
<% for i in 0..(ENV['TIMES'] ? ENV['TIMES'].to_i : 2) do %>
<p>Hello World #<%= i %>!</p>
<% end %>
The heroku local command automatically sets up the environment based on the contents of the .env file in your local directory. In the top level directory of your sample project, there’s already a .env file that contains:
TIMES=10
If you run the app with heroku local --port=5006, you see “Hello World” ten times when you refresh your browser.
To set the config var on Heroku, execute the following:
$ heroku config:set TIMES=10
Setting TIMES and restarting fierce-lake-02376... done, v5
TIMES: 10
View the app’s config vars using heroku config:
$ heroku config
TIMES: 10
...
To see this change in action, deploy your changed application to Heroku.
Use a Database
Listing the config vars for your app displays the URL that your app uses to connect to the database, DATABASE_URL:
$ heroku config
DATABASE_URL: postgres://xx:yyy@host:5432/d8slm9t7b5mjnd
...
Heroku also provides a pg command that shows a lot more information:
$ heroku pg
=== DATABASE_URL
Plan: essential-0
Status: Available
Connections: 0/20
PG Version: 18.4
Created: 2026-10-16 11:04
Data Size: 7.91 MB / 1 GB (0.77%) (In compliance)
Tables: 0/4000 (In compliance)
Fork/Follow: Unsupported
Rollback: Unsupported
Continuous Protection: On
Add-on: postgresql-globular-93680
The example app you deployed already has database functionality. It has a controller and database model for widgets, used by your app’s /widgets page. You can visit the page by appending /widgets to your app’s URL.
If you visit the URL, you see an error page appear. Check out the error message using heroku logs or in Papertrail to see something like this:
PG::UndefinedTable: ERROR: relation "widgets" does not exist
This error indicates that while we could connect to the database, the widgets table wasn’t found. You can fix that error by running rake db:migrate via heroku run:
$ heroku run "rake db:migrate db:migrate:status"
Running rake db:migrate db:migrate:status on fierce-lake-02376... starting, run.1139
Running rake db:migrate db:migrate:status on fierce-lake-02376... connecting, run.1139
Running rake db:migrate db:migrate:status on fierce-lake-02376... up, run.1139
database: ddtmbv0h3tag8h
Status Migration ID Migration Name
--------------------------------------------------
up 20140707111715 Create widgets
Now if you visit the /widgets page of your app again, you can list and create widget records.
If you have Postgres installed locally, you can also interact directly with the database. For example, here’s how to connect to the database using psql and execute a query:
$ heroku pg:psql
d8slm9t7b5mjnd=> \x
d8slm9t7b5mjnd=> select * from widgets;
-[ RECORD 1 ]---------------------------
id | 1
name | My Widget
description | It's amazing
stock | 100
...
Read more about Heroku PostgreSQL.
Delete Your App
Remove the app from your account. We only charge you for the resources you used.
This action permanently deletes your application and any add-ons attached to it.
$ heroku apps:destroy
You can confirm that your app is gone with this command:
$ heroku apps --all
Next Steps
You now know how to configure and deploy a Ruby app, view logs, and start a console.
To learn more, see: