So I’m creating another application for my portfolio that will be a tracking tool for sales professionals. In several previous positions I’ve been in charge of sales teams or even entire divisions. Part of being a good manager/director is helping the representatives with their cold calls. One of the most basic ways to help sales reps stay productive and profitable is to track call volume (how many calls they make each day). Another basic metric worth tracking is call time (how long they actually talk to each person they’re calling each day). Now when call time is low, call volume needs to be high (if you’re not talking for very long you have time to make more calls) and vice-versa. Another metric I used to track personally (before I was managing anyone and I was tracking my activity just for myself) was how many calls I made where we talked for at least x amount of time. When I was a freight broker that number used to be 4 minutes. The belief at the time was that if you could keep someone talking for 4 minutes, than you could reasonably determine if they really had no need for your service or if they were just trying to get you off of the line.
The application I’m currently building is a tool for sales managers and representatives accurately track the above metrics and then see where they need to improve. Now I know I’m going to host this application on heroku and today we’re going to look at how to make that happen.
Get the database ready
So if we were preparing for heroku from the beginning we could just create our rails application with the following command:
command line $ rails new myapp --database=postgresql
But I’ve already created my application in Cloud9 (plus I just enjoy this order of operations more) so we’ll have to retrofit it. First we’ll have to add a couple of gems to our production environment:
Gemfile group :production do gem 'pg' gem 'rails_12factor' end
We also need to move our sqlite3 gem from the main area to just our development environment so that it will look like this:
Gemfile group :development, :test do gem 'byebug' gem 'sqlite3' end
And then we’ll install the gems with:
Command Line $ bundle install
Now we just need to commit all of our changes to our github repository:
Command Line $ git add -A $ git commit -m "prepared app for Heroku" $ git push
Creating the Heroku App
Now that our application is ready we just need to create the Heroku app. We’ll do this by entering:
Command Line $ heroku create
You’ll probably have to enter your heroku email and password to sign into your account. You can then confirm that the remote was added to your project by typing:
Command Line $ git config --list | grep heroku
If you see
fatal: not in a git directory than there was an error. Otherwise you’re ready to deploy!
Command Line $ git push heroku master
Once that’s complete, it’s time to migrate your database:
Command Line $ heroku run rake db:migrate
And now if you visit your app it should be up and running!
We can rename our application on Heroku’s servers by using the rename command. I want my new app to be called dialtrack, so I would type:
Command Line $ heroku apps:rename dialtrack