visit
# production:
# url: <%= ENV['DATABASE_URL'] %>
production:
<<: *default
url: <%= ENV['DATABASE_URL'] %>
#username: tempGradientRailsJsonAPIJS
#password: <%= ENV['TEMPGRADIENTRAILSJSONAPIJS_DATABASE_PASSWORD']%>
Endpoints: This is easy just use [your apps name] + .herokuapp.com. So gave me my saved cities in my database. This makes sense as in my rails routes I have:
get '/cities.json', to: 'cities#index'
Rails/Rake commands
Heroku honors most rails/rake commands. On the Heroku dashboard you can open a console and run rake db:seed for example and put your seeded data into the database. This is the entire reason I wrote this article because there are many resources telling you how to drop your Heroku database online. HEROKU DOES NOT LET YOU DROP YOUR TABLE. THERE IS NO rake db:drop ALLOWED. To do so you need the Heroku dashboard
This is if you need to drop your database and you can just click reset.
FULL TEXT ARTICLE:
Development includes designing and coding out a full stack Ruby on Rails REST api with a JavaScript front end. That’s fine while you are testing your localhost:3000 endpoints and even getting data from a 3rd party API(openweathermap). I wrote about this .
Production could mean many different things. Let's ask Wikipedia: . Okay that is perfect because just it is just like Computer Science; confusing and not really for human eyes. I’ll use “Putting a site live on the Web” as our definition for production. Heroku is a cloud based platform that will host your application live on the web for you. Under the hood Heroku uses AWS and will take your code, package it, modify it, and spin up a live working version. There is a lot you have to do going from localhost:3000 to https//your-heroku-app/herokuapp.com.
First you need to get your database.yml file in order.
When you first generated your rails app it created a lot for you. This includes the database.yml file which contains sections:default:
development:
test:
production:
# On Heroku and other platform providers, you may have a full connection URL
# available as an environment variable. For example:
#
# DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
#
# You can use this database configuration with:
#
# production:
# url: <%= ENV['DATABASE_URL'] %>
production:
<<: *default
url: <%= ENV['DATABASE_URL'] %>
[{"id": 1,"name": "Phoenix","region": "southwest","created_at": "2020-10-27T13:43:21.239-07:00","updated_at": "2020-10-27T13:43:21.239-07:00","fetchURL": "//api.openweathermap.org/data/2.5/weather?q=Phoenix,us&units=imperial&APPID=fe2a775f427aa5fc92ce0379937b9ee9"},{"id": 2,"name": "Columbus","region": "Midwest","created_at": "2020-10-27T13:43:21.250-07:00","updated_at": "2020-10-27T13:43:21.250-07:00","fetchURL": "//api.openweathermap.org/data/2.5/weather?q=Columbus,us&units=imperial&APPID=fe2a775f427aa5fc92ce0379937b9ee9"},{"id": 3,"name": "Boston","region": "east","created_at": "2020-10-27T13:43:21.258-07:00","updated_at": "2020-10-27T13:43:21.258-07:00","fetchURL": "//api.openweathermap.org/data/2.5/weather?q=Boston,us&units=imperial&APPID=fe2a775f427aa5fc92ce0379937b9ee9"},{"id": 4,"name": "Orlando","region": "southeast","created_at": "2020-10-27T13:43:21.267-07:00","updated_at": "2020-10-27T13:43:21.267-07:00","fetchURL": "//api.openweathermap.org/data/2.5/weather?q=Orlando,us&units=imperial&APPID=fe2a775f427aa5fc92ce0379937b9ee9"},{"id": 5,"name": "Seattle","region": "northwest","created_at": "2020-10-27T13:43:21.275-07:00","updated_at": "2020-10-27T13:43:21.275-07:00","fetchURL": "//api.openweathermap.org/data/2.5/weather?q=Seattle,us&units=imperial&APPID=fe2a775f427aa5fc92ce0379937b9ee9"}]
Now once your endpoints are hitting and you have your database.yml file in order you might want to drop your database. I know in development I did this a lot. Sometimes you need to clear out your database and start over. There are many articles describing how to do this. I want to make this crystal clear. HEROKU DOES NOT LET YOU DROP YOUR DATABASE. You can waist your time trying but it will now work. You have to go to your Heroku dashboard and then open your database here:
Now from here you mush RESET your database.
Also published on: //software-for-humanity.medium.com/heroku-production-tldr-how-to-go-live-with-your-rails-app-7a7aabf22c4