Unlimited Plugins, WordPress themes, videos & courses! Unlimited asset downloads! From $16.50/m
Ruby heroku 1
  • Overview
  • Transcript

2.2 Prepare the Application for Production

We now have our software requirements ready. The next step is to prepare our Rails app to conform with Heroku's way of running applications.

2.2 Prepare the Application for Production

At this point in time, we have the project registered in the Heroku system. But now we need to prepare our application in order to suit the Heroku system. There are some dependencies that we need to satisfy in order for the application to run smoothly. The main set of dependencies that we need to satisfy are in the gem file. When we go to the gem file, we have some things that shouldn't really be there. And there are some things that are not there and should be. So, let's see what we should do in regards to our application. The first thing that we have is the SQLite gem. This gem should not be in the production environment. So we need to focus this on a separate group, specifically this one. The development and test groups should have this SQLite gem, but the production environment should have another gem of its own. So specify a group called production and will add two gems, P.T. gem and also the rails12_factor gem. This gem in specific allows us to integrate some missing parts of the real stack. If you're unsure about this gem, then just leave it as it is in development. But Heroku might complain and so just add in this gem. Next we're going to type in the bundle command, just to make sure that everything is up and running in development. To do that we're going to pass in a special flag called without. We'll need to strip the production settings because up until now we haven't messed around with postgres. That's what the pg gem does, it integrates a postgres database with our application. So just type in that, and all of the gems will be bundled in as usual with the specific consideration of the SQLite gem. It seems that I've made a mistake in the Rails 12 factor gem, most likely a typo, so let me just double check that. Okay, so instead of the underscore here it should be back here. So rails_12factor. Let's try and do the bundle command once again and see what the results will be. Even though the gem was provided in the production group, it still needs to be validated. Notice how we didn't have any trouble in regards to the post res gem. Because we didn't install it really, it didn't throw any errors whatsoever. So from here we're good to go, at least as far as the gem file goes. We still need to go to db/database.yamlfile. Because we call the repository, the YAML file won't be there. So we're gonna have to create a new database file. So in the file we'll create a production group which will have an adapter key, which will match post press SQL and then the encoding will also be unicode. We want the database to the a UTF eight database. Let's finally pick up on the pull which is basically a timeout to reach out to the data. We'll set it to five seconds. This is all we need in regards to the production environment. We don't need any username or password combinations. Heroku will take care of that for us. So that's really it for now. We have the dependencies specified in the production group, the remainder of the dependencies have been dealt with, specifically the SQLite Gem. And also the database YAML file contains the information that's necessary for the database to run in Heroku. From here, we'll be able to deploy the application. Jump into the next lesson to learn how we can do it.

Back to the top