housework

rails

From start to finish: Install Ruby on Rails on OSX, Deploy on Heroku

Ruby on Rails is one of the most popular web development frameworks, and Heroku has become a popular place to quickly deploy applications – and both for very good reason. For this guide, you will need a Heroku account (it’s free to sign up). This guide also assumes that you’re running OSX 10.10. Beyond those two assumptions we will try to go from ground zero to have a local rails development environment and an environment on Heroku.

Tools:

  • 1 ea OSX 10.10
  • 1 ea Heroku Account
  • 1 ea Ruby 2.0
  • 1 ea Rails 4.2
  • 1 ea RVM
  • 1 ea git
  • 1 ea xcode

1Install Xcode

If Xcode is already installed, you can skip this step. To check, open your Terminal application and type:

xcode-select -p If Xcode is installed you will see the path in the Applications directory:

/Applications/Xcode.app/Contents/Developer If it’s not installed type:

xcode-select --install and you will be prompted to install the Xcode Command Line Tools.

After installing, verify the install:

$ xcode-select -p /Applications/Xcode.app/Contents/Developer and finally ensure gcc is installed:

$ gcc --version Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn) Target: x86_64-apple-darwin14.1.0 Thread model: posix

2Configure git

Git is a popular version control software, and it will be required to push to Heroku in later steps. If you’ve successfully installed Xcode, git will be installed as well. You can go ahead and configure git now.

First, you can confirm that git is installed:

$ git --version git version 1.8.3.4 (Apple Git-47) and now configure it by typing:

$ git config --global user.name "Your Real Name" $ git config --global user.email me@example.com $ git config -l --global user.name=Your Real Name user.email=me@example.com The above commands will set your name and your email address. Then the third line simply checks to make sure they were set properly. These values will be used to identify your commits.

3Install Homebrew

Homebrew is a popular package manager for OSX. There are other great package managers, but for this guide we will use homebrew.

To install type:

$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

4Install RVM

RVM is the ruby version manager. This allows you to have multiple ruby environments on the same machine. You may not need multiple environments, but it’s the easiest way to setup the environment you need for this guide.

To install type:

curl -L https://get.rvm.io | bash -s stable --ruby

The –ruby flag installs the latest version of ruby.

5Check RubyGems version

RubyGems should be installed, but you can check the version with this:

$ gem -v 2.4.6 and update if necessary:

$ gem update --system To check which gems are installed in the global gemset, use:

$ rvm gemset use global $ gem list This will list your gems, and if you’d like you can update any stale gems:

gem update I also recommend using the following the speed up gem installation by disabling documentation:

$ echo "gem: --no-document" >> ~/.gemrc Lastly, we should install Nokogiri in the global gemset. Many gems, including rails, depend on Nokogiri.

$ gem install nokogiri

6Install rails

For this guide, we will create a new gemset to install for this specific version of rails. You could skip this command and by default you would be installing rails in the global gemset.

To make a gemset for the current stable release type:

$ rvm use ruby-2.2.0@rails4.2 --create At the time of this writing, rails 4.2 is the current version. If a new version is out you can name the gemset it appropriately.

Use the following to install the latest version of rails:

$ gem install rails After it finishes installing, check that rails is installed:

$ rails -v

7Create a folder for your project

I typically keep all of my development projects in ~/Developer, but you can organize your projects however you’d like.

To follow my example, let’s create the Developer folder as well as our specific project folder:

$ mkdir -p ~/Developer/my_rails_project

8Get an account on Heroku

At this point, we’re going to switch gears. You could skip straight to creating your rails app and worry about this step later if you’d like, but I think this is the most logical point to get your heroku environment setup.

As mentioned in the guide description, you’ll need to set up an account on Heroku. It’s free to sign up, so go ahead and do that if you haven’t already. Make sure to remember your login information.

9Install the Heroku toolbelt

Install the Heroku Toolbelt. This gives you access to the Heroku command line tools, which allow you to deployment your project files to your Heroku environment which we will do in subsequent steps.

10Log in to Heroku

With the Heroku Toolbelt installed, go ahead and log in to Heroku in your console. To do this type:

$ heroku login You will be prompted to enter your email address and password.

11Install and configure Postgres

Heroku requires postgres so we will use postgress in our development environment as well. We’ll install using homebrew, like this:

$ brew install postgres Then run this command to finish installing the database:

$ initdb /usr/local/var/postgres Run the following commands to start postgres upon login:

$ mkdir -p ~/Library/LaunchAgents $ ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents $ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist Now, you can install the postgres gem that will be required for your rails application:

$ gem install pg

12Create your rails app

If you followed my example for setting up your project folders you can cd into your project folder like this:

cd ~/Developer/my_rails_project From within your project folder, you can create your rails app like this:

rails new . --database=postgresql Next, we should make sure all necessary gems are installed. The following command will check and install all gems in your Gemfile. So if you install a gem on your local environment, you need to add it to your Gemfile as well. While developing, you’ll find that many bugs can be fixed by either making sure your Gemfile is up to date or simply running the following command.

$ bundle install

13Configure your local database

Rails makes this part easy. Once you’ve got your rails app created simply run the following two commands from the command line:

$ rake db:create:all $ rake db:migrate

14Now let’s test our local environment

We should be setup and ready to start developing, but first let’s test our local environment.

From your project root, run:

$ rails server

This will create a local webserver running your rails application. To visit see your app, go to http://localhost:3000 in a web browser.

You should see the Rails welcome page.

Now let's test our local environment

15Deploy the app to heroku

Now that we’ve got a working – although quite boring – rails application, we can go ahead and push our code to Heroku. You might decide in the future to build out your application a little more before deploying, but for this guide we will just deploy our bare application so you can get familiar with the process.

First we’ll want to initialize this application in git.

$ git init $ git add . $ git commit -m "init"

This initializes, adds all of the code, and creates your first commit message.

Now we’ll create our heroku application. This can also be done from the Heroku website, but we’ll do it here for simplicity.

$ heroku create

Now verify that the remote app was created:

$ git config --list | grep heroku remote.heroku.url=https://git.heroku.com/simpleregistry.git remote.heroku.fetch=+refs/heads/*:refs/remotes/heroku/*

Now we can deploy our code:

$ git push heroku master

16Test our heroku environment

We’ll want to view our application on Heroku, even if it doesn’t do anything interesting.

So first we’ll make sure we have one dyno running the web process:

$ heroku ps:scale web=1

And double check that the process is running:

$ heroku ps === web (1X): `bin/rails server -p $PORT -e $RAILS_ENV` web.1: up 2015/02/23 09:06:08 (~ 1m ago)

Now, let’s check out our application in the browser!

$ heroku open

This will open up a new browser tab to view your application on heroku. Since this is the production environment, we won’t get any error messages or the rails test page. It will simply 404 since we haven’t set up any routes or controllers. But at least we know it’s working.

Now you can start writing your rails application and future deployments can be achieved through the command we used initially:

$ git push heroku master

Test our heroku environment

17Further reading

If you found any issues with this guide, please report them. I’m hoping this can serve as a great guide for beginners and a reference for more experienced developers.

Install Ruby on Rails on Mac OS X

http://railsapps.github.io/installrubyonrails-mac.html

Getting started with rails 4.x on Heroku

https://devcenter.heroku.com/articles/getting-started-with-rails4

Installing Postgres on Mac OSX

http://www.gotealeaf.com/blog/how-to-install-postgresql-on-a-mac

Getting started with Rails

http://guides.rubyonrails.org/getting_started.html


Now learn about:


Discuss this guide

var disqus_shortname = ‘howchootest’; (function() { var dsq = document.createElement(‘script’); dsq.type = ‘text/javascript’; dsq.async = true; dsq.src = ‘//’ + disqus_shortname + ‘.disqus.com/embed.js’; (document.getElementsByTagName(‘head’)[0] || document.getElementsByTagName(‘body’)[0]).appendChild(dsq); })();

Tools:

  • 1 ea OSX 10.10
  • 1 ea Heroku Account
  • 1 ea Ruby 2.0
  • 1 ea Rails 4.2
  • 1 ea RVM
  • 1 ea git
  • 1 ea xcode

wireless

How to generate a secure, random password

Most people use the same password for every account they have on the Internet. This is highly insecure for obvious reasons. For important accounts that you need to keep protected it’s a good idea to generate a random secure password.

1Generate a random password

There are plenty of tools across the internet that will help you generate random passwords. I recommend using a password manager, and many password managers come with a password generator built in. These are generally reliable for creating secure passwords. As a guide, an 8 character random password usually takes a few days to crack whereas a 10 character password takes years. Obviously the more characters you use the more secure the password assuming it is completely random.

2Test the security

Once you generate your password you can go to howsecureismypassword.net. Simply enter your password, and it will let you know how long it takes a normal desktop computer to crack it!


Now learn about:


Discuss this guide

var disqus_shortname = ‘howchootest’; (function() { var dsq = document.createElement(‘script’); dsq.type = ‘text/javascript’; dsq.async = true; dsq.src = ‘//’ + disqus_shortname + ‘.disqus.com/embed.js’; (document.getElementsByTagName(‘head’)[0] || document.getElementsByTagName(‘body’)[0]).appendChild(dsq); })();

How to adjust your Hario Mini Mill coffee grinder

The Hario Mini Mill grinder makes an affordable, high quality coffee grinder if you set it up properly. Unfortunately, the directions are not very clear as to how to adjust for the perfect grind.

1Screw adjustment nut all the way down

Remove the bottom canister and screw the adjustment nut as tight as it goes. This serves as a reference for the next step.

Screw adjustment nut all the way down

2Unscrew the adjustment nut to the proper setting

The way to measure your grind is by “clicks” away from all the way tight. You’ll feel the nut click as you unscrew, so count the number of clicks. The number of clicks to unscrew should vary based on the brew method you’re using. Here’s the general guide I use: Standard Drip Brew: 10 clicks #2 Pour over: 10 clicks Aeropress: 6-8 clicks Espresso: 5 clicks French Press: 12-14 clicks Moka pot: 9 clicks Chemex: 9 clicks Also if you’re looking for the more vague ones: Medium fine: 8 clicks Medium: 10 clicks Medium coarse: 12 clicks credit to u/Iwannayoyo for the vague ones

Unscrew the adjustment nut to the proper setting

3Follow this chart for options not listed

Follow this chart for options not listed

Now learn about:


Discuss this guide

var disqus_shortname = ‘howchootest’; (function() { var dsq = document.createElement(‘script’); dsq.type = ‘text/javascript’; dsq.async = true; dsq.src = ‘//’ + disqus_shortname + ‘.disqus.com/embed.js’; (document.getElementsByTagName(‘head’)[0] || document.getElementsByTagName(‘body’)[0]).appendChild(dsq); })();

How to flush dns on Mac OS 10.7 or 10.8

by daynejones in osx, mac | 1 min

Flushing your dns is a very useful troubleshooting step and is necessary for some network changes to take effect. For some reason, Apple likes to change the command to clear the dns cache with just about every OS update, so here is the old command.

1Open Terminal

This is located in Applications > Utilities

2Execute the following command

sudo killall -HUP mDNSResponder


Now learn about:


Discuss this guide

var disqus_shortname = ‘howchootest’; (function() { var dsq = document.createElement(‘script’); dsq.type = ‘text/javascript’; dsq.async = true; dsq.src = ‘//’ + disqus_shortname + ‘.disqus.com/embed.js’; (document.getElementsByTagName(‘head’)[0] || document.getElementsByTagName(‘body’)[0]).appendChild(dsq); })();

How to access the balance manager in the new Paypal UI

Dayne Dayne (57)
Total time: 1 minute 
Updated: February 18th, 2015

Since the UI has changed, there is literally no way to manage your balance manager, or the way that paypal decided when to take money from your account.

Posted in these interests:

paypal
PRIMARY
1 guide
finance
1 guide

How to access the balance manager in the new Paypal UI

paypalfinance
Dayne Dayne (57)
Total time: 1 minute 
Updated: February 18th, 2015
Dayne
 

Posted in these interests:

paypal
PRIMARY
1 guide
finance
1 guide
paypal
PRIMARY
1 guide
finance
1 guide
PRIMARY
Calling all writers!

We’re hiring. Write for Howchoo

 
In these interests
paypal
PRIMARY
1 guide
finance
1 guide
paypal
PRIMARY
1 guide
finance
1 guide
PRIMARY

Make sure you’re logged into your paypal account

Calling all writers!

We’re hiring. Write for Howchoo

Dayne's profile pictureDayne
Joined in 2015
Software engineer, co-founder of Howchoo, and renaissance man. Lifelong amateur woodworker, espresso mechanic, freestyle lyricist, drummer, artist, runner, coffee roaster, electrical engineer, gamer, inventor, churner, psychoanalyst, photographer, pizza chef, pit master, audiophile, guitarist, entrepreneur, dad, yogi, cyclist, and barista.
Dayne's profile picture
Share this guide!
RedditEmailText
Posted in these interests:
paypalpaypal
paypal
PRIMARY
PRIMARY
ExploreExplore
Discuss this guide:
We’re hiring!
Are you a passionate writer? We want to hear from you!
We’re hiring!
Are you a passionate writer? We want to hear from you!
View openings

Want to support Howchoo? When you buy a tool or material through one of our Amazon links, we earn a small commission as an Amazon Associate.

Donate

How to flush dns on Mac OS 10.7 or 10.8

How to flush dns on Mac OS 10.7 or 10.8How to flush dns on Mac OS 10.7 or 10.8
Dayne Dayne (57)
Total time: 1 minute 
Updated: February 18th, 2015

Flushing your dns is a very useful troubleshooting step and is necessary for some network changes to take effect. For some reason, Apple likes to change the command to clear the dns cache with just about every OS update, so here is the old command.

Posted in these interests:

osx
PRIMARY
47 guides
mac
81 guides

How to flush dns on Mac OS 10.7 or 10.8

How to flush dns on Mac OS 10.7 or 10.8How to flush dns on Mac OS 10.7 or 10.8
Dayne Dayne (57)
Total time: 1 minute 
Updated: February 18th, 2015

Flushing your dns is a very useful troubleshooting step and is necessary for some network changes to take effect. For some reason, Apple likes to change the command to clear the dns cache with just about every OS update, so here is the old command.

Posted in these interests:

osx
PRIMARY
47 guides
mac
81 guides

How to flush dns on Mac OS 10.7 or 10.8

How to flush dns on Mac OS 10.7 or 10.8How to flush dns on Mac OS 10.7 or 10.8
Dayne Dayne (57)
Total time: 1 minute 
Updated: February 18th, 2015

Flushing your dns is a very useful troubleshooting step and is necessary for some network changes to take effect. For some reason, Apple likes to change the command to clear the dns cache with just about every OS update, so here is the old command.

Posted in these interests:

osx
PRIMARY
47 guides
mac
81 guides

How to flush dns on Mac OS 10.7 or 10.8

How to flush dns on Mac OS 10.7 or 10.8How to flush dns on Mac OS 10.7 or 10.8
Dayne Dayne (57)
Total time: 1 minute 
Updated: February 18th, 2015

Flushing your dns is a very useful troubleshooting step and is necessary for some network changes to take effect. For some reason, Apple likes to change the command to clear the dns cache with just about every OS update, so here is the old command.

Posted in these interests:

osx
PRIMARY
47 guides
mac
81 guides

How to flush dns on Mac OS 10.7 or 10.8

osxmac
Dayne Dayne (57)
Total time: 1 minute 
Updated: February 18th, 2015
Dayne
1
 

Posted in these interests:

osx
PRIMARY
47 guides
mac
81 guides
osx
PRIMARY
47 guides
mac
81 guides
PRIMARY
Calling all writers!

We’re hiring. Write for Howchoo

1
 
In these interests
osx
PRIMARY
47 guides
mac
81 guides
osx
PRIMARY
47 guides
mac
81 guides
PRIMARY

This is located in Applications > Utilities


sudo killall -HUP mDNSResponder


This is located in Applications > Utilities

This is located in Applications > Utilities

Open Terminal


sudo killall -HUP mDNSResponder



sudo killall -HUP mDNSResponder


Execute the following command

Calling all writers!

We’re hiring. Write for Howchoo

Dayne's profile pictureDayne
Joined in 2015
Software engineer, co-founder of Howchoo, and renaissance man. Lifelong amateur woodworker, espresso mechanic, freestyle lyricist, drummer, artist, runner, coffee roaster, electrical engineer, gamer, inventor, churner, psychoanalyst, photographer, pizza chef, pit master, audiophile, guitarist, entrepreneur, dad, yogi, cyclist, and barista.
Dayne's profile picture
Share this guide!
RedditEmailTextPinterest
Related to this guide:
How to enable the dashboard in OS X El CapitanHow to enable the dashboard in OS X El Capitan
As someone who uses OS X dashboard widgets often, I was dismayed to find out that Apple has hidden it by default. Thankfully, it’s easy to reenable the dashboard in El Capitan. Here’s how to do it.
Zach's profile picture ZachView
In these interests: osxmacelcapitan
How to delete an application on Mac OS XHow to delete an application on Mac OS X
There are a few different methods for deleting an application based on how you installed it.
Tyler's profile picture TylerView
In these interests: osxmac
How to Delete an Application Downloaded from the Mac App StoreHow to Delete an Application Downloaded from the Mac App Store
This guide will teach you how to quickly delete an application from your Mac that was downloaded from the Mac App Store. This method uses Launchpad.
Tyler's profile picture TylerView
In these interests: osxmac
How to enable the dashboard in OS X El CapitanHow to enable the dashboard in OS X El Capitan
As someone who uses OS X dashboard widgets often, I was dismayed to find out that Apple has hidden it by default. Thankfully, it’s easy to reenable the dashboard in El Capitan. Here’s how to do it.
Zach's profile picture ZachView
In these interests: osxmacelcapitan
Zach's profile pictureViewosxmacelcapitan
How to delete an application on Mac OS XHow to delete an application on Mac OS X
There are a few different methods for deleting an application based on how you installed it.
Tyler's profile picture TylerView
In these interests: osxmac
Tyler's profile pictureViewosxmac
How to Delete an Application Downloaded from the Mac App StoreHow to Delete an Application Downloaded from the Mac App Store
This guide will teach you how to quickly delete an application from your Mac that was downloaded from the Mac App Store. This method uses Launchpad.
Tyler's profile picture TylerView
In these interests: osxmac
Tyler's profile pictureViewosxmac
People also read:
Many applications use multiple windows, and there is a handy keyboard shortcut to help you switch quickly between them.
There are plenty of websites that will automatically convert a video into a gif. Some of these sites even have a few options to customize the gif you create.
This guide shows you how to change the HipChat notification sound in both Mac and Windows. Presently, the notification sound cannot be changed through either native application.
Flushing your dns is a very useful troubleshooting step and is necessary for some network changes to take effect.
This guide was written for OS X 10.9. For an updated version of this guide click here. There are plenty of reasons you will want to encrypt files on your personal computer.
This shortcut takes your cursor directly to the searchbox after opening Mail.app. This works in all current versions of OSX.
This short guide shows you how to disable the additional Mac menubars/toolbars and docks that were added in OS X Mavericks.
As a website designer, I work with a lot of files — and a lot of file types. Nothing’s worse than wasting time trying to fix a problem caused by an overseen missing file extension.
You can set up your Apple computer so that when you double-click the menu bar it minimizes the application. This is a huge time saver and is OS X does not do this by default.
I have tons of photos and this was seriously slowing my computer down. It took a bit of hunting to figure out how to do this since the option is apparently not in iTunes.
Many applications use multiple windows, and there is a handy keyboard shortcut to help you switch quickly between them.
There are plenty of websites that will automatically convert a video into a gif. Some of these sites even have a few options to customize the gif you create.
This guide shows you how to change the HipChat notification sound in both Mac and Windows. Presently, the notification sound cannot be changed through either native application.
Flushing your dns is a very useful troubleshooting step and is necessary for some network changes to take effect.
This guide was written for OS X 10.9. For an updated version of this guide click here. There are plenty of reasons you will want to encrypt files on your personal computer.
How to switch between the windows of an application on OS X
How to turn a video into a gif on a Mac
How to change the HipChat notification sound
How to flush DNS on Mac OS X Yosemite
How to encrypt files on Mac OS X 10.9
This shortcut takes your cursor directly to the searchbox after opening Mail.app. This works in all current versions of OSX.
This short guide shows you how to disable the additional Mac menubars/toolbars and docks that were added in OS X Mavericks.
As a website designer, I work with a lot of files — and a lot of file types. Nothing’s worse than wasting time trying to fix a problem caused by an overseen missing file extension.
You can set up your Apple computer so that when you double-click the menu bar it minimizes the application. This is a huge time saver and is OS X does not do this by default.
I have tons of photos and this was seriously slowing my computer down. It took a bit of hunting to figure out how to do this since the option is apparently not in iTunes.
Mac Mail Search Box Shortcut
Remove Multiple Menu Bars and Docks in macOS/OS X
Always show file extensions in Mac OSX
Double-Click the Menu Bar to Minimize an Application in macOS
How to Stop iPhoto From Opening When You Connect Your iPhone or iPad
Posted in these interests:
osxosx
osx
PRIMARY
OS X is a series of Unix-based operating systems developed by Apple, Inc. The first public beta, called Kodiak, appeared in 2000.
osxosx
osx
PRIMARY
OS X is a series of Unix-based operating systems developed by Apple, Inc. The first public beta, called Kodiak, appeared in 2000.
PRIMARY
ExploreExplore
Discuss this guide:
We’re hiring!
Are you a passionate writer? We want to hear from you!
We’re hiring!
Are you a passionate writer? We want to hear from you!
View openings

Want to support Howchoo? When you buy a tool or material through one of our Amazon links, we earn a small commission as an Amazon Associate.

Donate
Tyler's profile pictureTyler
Joined in 2015
Software Engineer and creator of howchoo.
Related to this guide:
Free Google Home Mini from SpotifyFree Google Home Mini from Spotify
Spotify is giving a Google Home Mini to every paying member.
Zach's profile picture ZachView
In these interests: spotifygoogle
How to Choose Which Calendars to Sync in Google CalendarHow to Choose Which Calendars to Sync in Google Calendar
I’m the kind of person who uses both Google and Apple products. All of my calendar data is saved to a few different Google calendars, but I generally use Apple’s Calendar on my Mac and iPhone.
Tyler's profile picture TylerView
In these interests: googleapple
How to Get the Sum of a Column in a Google Drive SpreadsheetHow to Get the Sum of a Column in a Google Drive Spreadsheet
This is a very simple guide on how to get the sum of a column in a Google Docs spreadsheet. If you have a list of numbers you want to add, here’s how.
hammerhead's profile picture hammerheadView
In these interests: google
People also read:
Don’t want to delete your passwords one at a time? No problem.
Google Chrome power users likely make use of profiles to manage various browsing contexts. There are many advantages to doing so.
Google Home-Enabled smart mirror
Magic mirror, on the wall, turn off the lights.
By default, the HTML exported from Google Docs includes tons of classes, styles, and is generally messy. This short guide will teach you how to export clean HTML devoid of classes and inline styles.
Everybody makes mistakes. At last, Google has given us the ability to undo sent emails in Gmail.
Tired of constantly closing the downloads bar in Chrome after a download has completed? As a web developer who constantly downloads things, I was too.
This command will allow you to view a complete list of shortcuts in Google Drive Spreadsheets.
Posted in these interests:
Discuss this guide:
We’re hiring!
Are you a passionate writer or editor? We want to hear from you!
We’re hiring!
Are you a passionate writer or editor? We want to hear from you!

Want to support Howchoo? When you buy a tool or material through one of our Amazon links, we earn a small commission as an Amazon Associate.

Want to support Howchoo? When you buy a tool or material through one of our Amazon links, we earn a small commission as an Amazon Associate.