Deploy A Rails App
Step 1: Commit to git
Type this in the shell:git add -AType this in the shell:git commit -m "initial commit"Expected result:a lot of lines like create mode 100644 GemfileType this in the shell:git logExpected result:(Your git name and "initial commit" message.)
Step 2: Create a Heroku application
Type this in the shell:heroku createExpected result:Enter your Heroku credentials. Email: myemail@example.com Password: Uploading ssh public key /Users/smei/.ssh/id_rsa.pub Creating app... done, ⬢ true-poppy-74911 https://true-poppy-74911.herokuapp.com/ | https://git.heroku.com/true-poppy-74911.gitType this in the shell:git remote showExpected result:heroku
Step 3: Configure the PostgreSQL database for heroku
# Use sqlite3 as the database for Active Record gem "sqlite3", "~> 1.4"# Use sqlite3 as the database in development and PostgreSQL in production group :development, :test do gem 'sqlite3' end group :production do gem 'pg' endproduction: <<: *default database: db/production.sqlite3production: adapter: postgresql encoding: unicode pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> url: <%= ENV["DATABASE_URL"] %>
Step 4: Prepare the Gemfile for deploying to a UNIX Server
Type this in the shell:bundle install --without productionApproximate expected result:... Bundle complete! 6 Gemfile dependencies, 54 gems now installed. Gems in the group 'production' were not installed. Use `bundle info [gemname]` to see where a bundled gem is installed.The greyed-out text may differ and is not important.Type this in the shell:bundle lock --add-platform x86_64-linux --add-platform rubyApproximate expected result:Fetching gem metadata from https://rubygems.org/.......... Resolving dependencies... Writing lockfile to ...railsbridge/test_app/Gemfile.lock
The greyed-out text may differ and is not important.
Step 5: Set the root route
Rails.application.routes.draw doroot 'drinks#index'
Step 6: Add the changes to git
Type this in the shell:git add .Type this in the shell:git commit -m "Updates for heroku deployment"
Step 7: Deploy (push) to heroku
Type this in the shell:git push heroku mainApproximate expected result:remote: -----> Discovering process types remote: Procfile declares types -> (none) remote: Default types for buildpack -> console, rake, web remote: remote: -----> Compressing... remote: Done: 37.3M remote: -----> Launching... remote: Released v6 remote: https://true-poppy-74911.herokuapp.com/ deployed to Heroku remote: remote: Verifying deploy... done. To https://git.heroku.com/true-poppy-74911.git * [new branch] main -> mainThe greyed-out text may differ and is not important.Type this in the shell:heroku run rails db:migrateApproximate expected result:Running rails db:migrate on ⬢ {/UZZY}true-poppy-74911{/FUZZY}... up, run.7760 (Free) I, [2022-07-01T10:52:50.899913 #4] INFO -- : Migrating to CreateDrinks (20220701102418) == 20220701102418 CreateDrinks: migrating ===================================== -- create_table(:drinks) -> 0.0174s == 20220701102418 CreateDrinks: migrated (0.0175s) ============================The greyed-out text may differ and is not important.
Step 8: Visit your new application
Approximate expected result:=== true-poppy-74911 Addons: heroku-postgresql:hobby-dev Auto Cert Mgmt: false Dynos: web: 1 Git URL: https://git.heroku.com/true-poppy-74911.git Owner: ....your email... Region: us Repo Size: 34 KB Slug Size: 37 MB Stack: heroku-20 Web URL: https://true-poppy-74911.herokuapp.com/The greyed-out text may differ and is not important.
Next Step:
Go on to Get A Sticker