Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
Installing a Ruby on Rails Development Environment in OS X11:04 with Jason Seifer
In this video, you'll learn how to install a Ruby on Rails Development Environment in OS X.
XCode can be installed from the App Store. The rest of these commands take place in a Terminal.
Command line tools come with it. Show app store.
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" brew update brew doctor
Install rbenv from Homebrew
brew install rbenv ruby-build echo "gem: --no-document" > ~/.gemrc
Install a ruby
rbenv install 2.2.1 rbenv global 2.2.1 rbenv rehash
Install a database
brew install mysql
Install other dependencies
brew install wget curl imagemagick
Download from the Sublime Text website.
ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/sublime
Install bundler and rails
In a terminal:
gem install bundler rbenv rehash gem install rails
git config --global user.name "Jason Seifer" git config --global user.email email@example.com
Create a new app
mkdir projects cd projects rails new testapp cd testapp subl -n . bin/rails server
Create a quick scaffold
bin/rails generate scaffold name title:string first:string last:string bin/rake db:migrate bin/rails s
Hi, I'm Jason, the Ruby teacher here at Tree House. 0:00 In this workshop, 0:03 we're going to be setting up a Ruby on Rails development environment in OS X. 0:04 Now in order to do that, we're going to need to install 0:09 the Ruby programming languages, as well as a few other dependencies. 0:12 OS X already comes with a version of Ruby installed. 0:16 However, it's usually a little bit out of date. 0:19 So instead, what we're gonna do is install Ruby via Homebrew, 0:22 using Ruby Build and rbenv. 0:27 Next we'll set up some databases, configure GIT, install a text editor, and 0:30 finally, generate a quick Ruby on Rails application, 0:35 to make sure everything is working. 0:38 So let's go ahead and get started. 0:40 So they first thing that we need to do, 0:42 in order to install a Rails Development Environment, is install Xcode. 0:43 So make sure that that is installed from the App Store. 0:48 Right here, I'm using a fresh install of OS X Yosemite, and 0:52 all that I've done is install Xcode from the App Store. 0:58 Not gonna make you watch all that, 1:01 because it takes a very long time to download and install. 1:04 So once Xcode is installed, what we need to do is launch a terminal, and 1:08 this is where most of our work is going to be done, the rest of this. 1:13 So, in order to get to terminal, over on the bottom here, 1:18 in Finder, head on over to the Applications folder. 1:23 And then scroll all the way down, and go into Utilities and 1:28 double-click on Terminal. 1:32 Then I'm gonna close the App Store right now, and also Finder. 1:36 So I'm going to make this a little bit bigger so that we can see it. 1:43 Okay. 1:49 So here's our Terminal window, and now we can start typing in our commands. 1:51 So the first thing that we need to do is install the command line tools for Xcode. 1:57 And that is going to let us build and compile Ruby. 2:02 So we do that by typing xcode=select then a space and 2:06 two dashes and the word install. 2:11 And now just click Install, and then read this fully and agree. 2:15 Then Xcode will go through, and find and download the command line tools. 2:21 Feel free to go get a hot or cold beverage while this happens. 2:27 Okay so once that finishes, click on Done. 2:32 And now there is one more command that we have to type in which is sudo 2:35 xcodebuild, and then a space, and license. 2:43 And this will agree to the terms and conditions of the Xcode license. 2:48 Please make sure that you read them fully before agreeing to it. 2:52 And then go ahead and type in your password. 2:56 Hit Enter. And then you'll have to read all of this. 3:00 I read very quickly, so this is, this is going, going very well for me. 3:03 Now then just type agree, and boom, 3:07 you have now installed and agreed to Xcode's terms and conditions. 3:11 So I'm gonna clear my screen here. 3:15 And now we're gonna install something called Homebrew, 3:18 which is described as the missing package manager for OS X. 3:21 Homebrew will let us install different command line software very easily, 3:26 and we're going to use that to install Ruby. 3:31 So double-click this line and copy it, then head back over to your Terminal. 3:33 And this part I'm just.make it full screen here so 3:41 we can see it a little bit better, and I'm gonna paste that. 3:43 And this tells me what it's going to install. 3:48 Now Homebrew will install and do its thing. 3:54 Okay, it says the installation is successful, so 3:58 I'm gonna clear my screen again. 4:01 Now let's just make sure Homebrew is up to date, we type in brew update. 4:03 Okay, that's up to date. 4:08 Next type in, brew doctor, and that will just check and 4:11 make sure everything installed okay. 4:14 All right, our system is ready to brew. 4:17 So now we can install Ruby. 4:22 We're going to install a project called rbenv, 4:25 which will manage our different Rubies for us. 4:27 And the other thing we're going to install is a project called ruby-build. 4:33 And this will download and install. 4:40 Okay, now we're almost done here, 4:46 rbenv needs us to add something to a certain file, 4:48 that launches when our Terminal launches, so what we need to do is, 4:53 take this line right here, and copy it. 4:58 And then type the word echo, a single quote, 5:05 paste, another single quote, a space, a greater than sign, 5:12 another space, a tilde, a slash, and the word, .profile. 5:18 And .profile is a file that gets executed by our Terminal 5:25 every time we open a Terminal. 5:30 And what this does is initializes rbenv. 5:33 There's one more thing that we want to do, which is type echo 5:36 gem: --no-document, 5:41 to a .gemrc file, also in our home directory. 5:48 So once we do that, we've set up rbenv's environment, 5:55 and we can either reload, or just type exit. 5:58 That'll be a little bit easier for us. 6:02 And now we can just load a new Terminal. 6:06 So I've launched a new Terminal. 6:13 I'm gonna make this full screen again here. 6:14 And now if I type in rbenv -v it shows I've got 6:17 Version 0.4.0 of rbenv installed. 6:22 Now I can go ahead and install a Ruby. 6:26 So, let's go ahead and install Ruby version 2.2.1. 6:29 [BLANK_AUDIO] 6:33 This will download, compile, and install Ruby 2.2.1 for us. 6:37 This may take a few minutes, so 6:44 feel free to go do something else while this installs and compiles. 6:45 Now once the Ruby version finishes downloading, installing, and 6:51 compiling, we need to tell rbenv to use it. 6:56 And the way we do that is by saying, rbenv global 2.2.1, 6:59 which is the version we just installed, and 7:04 then type rbenv rehash, and 7:08 rbenv rehash is going to just set that as the global version of Ruby. 7:12 Now if we type ruby -v, we see we've got Ruby version 2.2.1 installed. 7:19 Okay, now before we install Rails, we're going to install a few other things. 7:26 And these are just, kind of, good command line programs to have, 7:31 we're going to install Wget, Curl, and imageMagick. 7:34 These aren't strictly necessary for a Rails installation, but 7:39 they are great to have. 7:44 And so Homebrew will download and install these for 7:45 us, and boom, those are all installed. 7:49 And then finally, we can go through, and 7:53 install the couple other things that we need for a Rails installation. 7:57 We need to install a Ruby gem called Bundler, and 8:02 we also need to install Rails. 8:10 Okay, so once Bundler and the Rails gems finish installing, 8:15 we have to type in one more thing which is, rbenv rehash. 8:20 And that will tell rbenv to use the binaries of Bundler and 8:25 Rails, that we just installed. 8:31 So now I'm going to kick this back out off full screen here, and 8:33 what we're going to do is grab a text editor called, Sublime Text. 8:40 And this is just, a preference, you don't need to install 8:49 Sublime Text if you already have a text editor that you work with, but 8:53 text editors are really good for editing codes, specifically Rails code. 8:57 Now double-click on Sublime Text to open it. 9:03 And then you can just grab that, and put that in your Applications folder. 9:06 And then, if we go over to the Applications folder, 9:17 we should have Sublime Text installed. 9:20 And just click Open. 9:24 OK. 9:26 Sublime Text is now installed. 9:27 I'm going to close it, and go back to my Terminal. 9:29 And here's a neat little command that we can use. 9:32 And you can copy and paste this from the notes right below the video. 9:38 But what this does right here is, creates a symbolic link 9:42 called sublime, which will let us open folders and 9:48 files inside of Sublime Text, right from the command line. 9:52 So once that's installed, now we can finally create a Rails application. 9:56 So I'm going to go into my Documents folder, and type, 10:02 rails new testapp, and that will generate a new Rails application. 10:06 So once that's done, I'm gonna clear my screen again here, type cd testapp/, and 10:15 then type, bin/rake db:create: all, that will create all of the databases for us. 10:21 And type, bin/rails server, and with any luck, we should see this message 10:28 saying that a new Rails application is started in the development mode. 10:35 And now we can copy that, and go to our web browser and paste it, 10:40 and we should see,welcome aboard, we are riding Ruby on Rails. 10:48 Great work, we now have installed and set up a Rails development environment. 10:54
You need to sign up for Treehouse in order to download course files.Sign up