Note: Your Ruby on Rails app must be set up in PostgreSQL, if it isn't, you will have to create a new Rails app in postgreSQL
-
Create a free heroku account if you don't have one already
-
Create a new App in Heroku, or select existing app you want to deploy to
-
Install toolbelt (only need this once, if it is a new computer install again, there is a link on heroku to download)
-
In App Settings > Reveal Config Variables > Edit "Secret_Key_base"
-
Get the secret key base from the rails app in config > secrets.yml > development: secret_key_base, and paste it in heroku
Make sure you are in the project directory on the master branch and the project is pushed up and merged to github type in console:
heroku login (enter heroku account email and pw)
heroku git:remote -a my_app_name_in_heroku <-- project name that you set up in heroku
git push heroku master
heroku run rake db:migrate
Under settings > heroku domain (copy and paste that url in a browser window)
- From inside your project folder, on the master branch, in command line:
git push heroku master
- Sometimes after updating an existing site, if there are errors on the site, run:
heroku run rake db:reset
heroku run rake db:migrate
In your heroku account, check the activity tab
FATAL: permission denied for database "postgres" / DETAIL: User does not have CONNECT privilege.
In the command line
heroku pg:reset DATABASE_URL
heroku run rake db:migrate
heroku run rake db:seed (IF there is a seed file)
- Make sure gem 'twitter' is included in your gem file
- add in the command line (in master branch):
heroku config:add TWITTER_CONSUMER_KEY=Your twitter consumer key
heroku config:add TWITTER_CONSUMER_SECRET=Your twitter consumer secret
heroku config:add TWITTER_ACCESS_TOKEN_KEY=Your twitter access token key
heroku config:add TWITTER_ACCESS_TOKEN_SECRET=Your twitter access token secret
Create a new Heroku account. Install the Heroku Toolbelt on your computer. The Heroku Toolbelt is installed by default in new Codecademy workspaces. In the terminal, log in using the email address and password you used when creating your Heroku account:
$ heroku login In Gemfile, add the pg gem to your Rails project. Change:
gem sqlite to
gem 'sqlite3', group: :development gem 'pg', '0.18.1', group: :production In Gemfile, add the rails_12factor gem::
gem 'rails_12factor', group: :production In the terminal, install the gems specified in the Gemfile:
$ bundle install Ensure config/database.yml is using the postgresql adapter. Change:
production: <<: *default database: db/production.sqlite3 to
production: <<: *default adapter: postgresql database: db/production.sqlite3 Commit your changes to git:
$ git add . $ git commit -m "Heroku config" In the terminal, create an app on Heroku:
$ heroku create Push your code to Heroku:
$ git push heroku master If you are using the database in your application, migrate the database by running:
$ heroku run rake db:migrate If you need to seed your database with data, run:
$ heroku run rake db:seed Get the URL of your app and visit it in the browser:
$ heroku apps:info In the output, copy the address in the Web URL field. Open a new tab in your browser, and visit your app.